@@ -1260,20 +1260,25 @@ private void validateProxyParameters(final Map<String, List<String>> optionsMap)
1260
1260
"Both proxyUsername and proxyPassword must be set together. They cannot be set individually" );
1261
1261
}
1262
1262
1263
- if (proxyHost != null && optionsMap . get ("proxyhost" ). size () > 1 ) {
1263
+ if (containsDuplicatedOptions ("proxyhost" , optionsMap ) ) {
1264
1264
throw new IllegalArgumentException ("Duplicated values for proxyHost: " + optionsMap .get ("proxyhost" ));
1265
1265
}
1266
- if (proxyPort != null && optionsMap . get ("proxyport" ). size () > 1 ) {
1266
+ if (containsDuplicatedOptions ("proxyport" , optionsMap ) ) {
1267
1267
throw new IllegalArgumentException ("Duplicated values for proxyPort: " + optionsMap .get ("proxyport" ));
1268
1268
}
1269
- if (proxyPassword != null && optionsMap . get ("proxypassword" ). size () > 1 ) {
1269
+ if (containsDuplicatedOptions ("proxypassword" , optionsMap ) ) {
1270
1270
throw new IllegalArgumentException ("Duplicated values for proxyPassword: " + optionsMap .get ("proxypassword" ));
1271
1271
}
1272
- if (proxyUsername != null && optionsMap . get ("proxyusername" ). size () > 1 ) {
1272
+ if (containsDuplicatedOptions ("proxyusername" , optionsMap ) ) {
1273
1273
throw new IllegalArgumentException ("Duplicated values for proxyUsername: " + optionsMap .get ("proxyusername" ));
1274
1274
}
1275
1275
}
1276
1276
1277
+ private boolean containsDuplicatedOptions (final String optionName , final Map <String , List <String >> optionsMap ) {
1278
+ List <String > optionList = optionsMap .get (optionName );
1279
+ return optionList != null && optionList .size () > 1 ;
1280
+ }
1281
+
1277
1282
private int countOccurrences (final String haystack , final String needle ) {
1278
1283
return haystack .length () - haystack .replace (needle , "" ).length ();
1279
1284
}
0 commit comments