@@ -505,7 +505,7 @@ public ConnectionString(final String connectionString, @Nullable final DnsClient
505
505
throw new IllegalArgumentException ("srvMaxHosts can not be specified with replica set name" );
506
506
}
507
507
508
- validateProxyParameters ();
508
+ validateProxyParameters (combinedOptionsMaps );
509
509
510
510
credential = createCredentials (combinedOptionsMaps , userName , password );
511
511
warnOnUnsupportedOptions (combinedOptionsMaps );
@@ -1226,7 +1226,7 @@ private void validatePort(final String port) {
1226
1226
}
1227
1227
}
1228
1228
1229
- private void validateProxyParameters () {
1229
+ private void validateProxyParameters (final Map < String , List < String >> optionsMap ) {
1230
1230
if (proxyHost == null ) {
1231
1231
if (proxyPort != null ) {
1232
1232
throw new IllegalArgumentException ("proxyPort can only be specified with proxyHost" );
@@ -1259,6 +1259,19 @@ private void validateProxyParameters() {
1259
1259
throw new IllegalArgumentException (
1260
1260
"Both proxyUsername and proxyPassword must be set together. They cannot be set individually" );
1261
1261
}
1262
+
1263
+ if (proxyHost != null && optionsMap .get ("proxyhost" ).size () > 1 ) {
1264
+ throw new IllegalArgumentException ("Duplicated values for proxyHost: " + optionsMap .get ("proxyhost" ));
1265
+ }
1266
+ if (proxyPort != null && optionsMap .get ("proxyport" ).size () > 1 ) {
1267
+ throw new IllegalArgumentException ("Duplicated values for proxyPort: " + optionsMap .get ("proxyport" ));
1268
+ }
1269
+ if (proxyPassword != null && optionsMap .get ("proxypassword" ).size () > 1 ) {
1270
+ throw new IllegalArgumentException ("Duplicated values for proxyPassword: " + optionsMap .get ("proxypassword" ));
1271
+ }
1272
+ if (proxyUsername != null && optionsMap .get ("proxyusername" ).size () > 1 ) {
1273
+ throw new IllegalArgumentException ("Duplicated values for proxyUsername: " + optionsMap .get ("proxyusername" ));
1274
+ }
1262
1275
}
1263
1276
1264
1277
private int countOccurrences (final String haystack , final String needle ) {
0 commit comments