@@ -1260,20 +1260,25 @@ private void validateProxyParameters(final Map<String, List<String>> optionsMap)
12601260 "Both proxyUsername and proxyPassword must be set together. They cannot be set individually" );
12611261 }
12621262
1263- if (proxyHost != null && optionsMap . get ("proxyhost" ). size () > 1 ) {
1263+ if (containsDuplicatedOptions ("proxyhost" , optionsMap ) ) {
12641264 throw new IllegalArgumentException ("Duplicated values for proxyHost: " + optionsMap .get ("proxyhost" ));
12651265 }
1266- if (proxyPort != null && optionsMap . get ("proxyport" ). size () > 1 ) {
1266+ if (containsDuplicatedOptions ("proxyport" , optionsMap ) ) {
12671267 throw new IllegalArgumentException ("Duplicated values for proxyPort: " + optionsMap .get ("proxyport" ));
12681268 }
1269- if (proxyPassword != null && optionsMap . get ("proxypassword" ). size () > 1 ) {
1269+ if (containsDuplicatedOptions ("proxypassword" , optionsMap ) ) {
12701270 throw new IllegalArgumentException ("Duplicated values for proxyPassword: " + optionsMap .get ("proxypassword" ));
12711271 }
1272- if (proxyUsername != null && optionsMap . get ("proxyusername" ). size () > 1 ) {
1272+ if (containsDuplicatedOptions ("proxyusername" , optionsMap ) ) {
12731273 throw new IllegalArgumentException ("Duplicated values for proxyUsername: " + optionsMap .get ("proxyusername" ));
12741274 }
12751275 }
12761276
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+
12771282 private int countOccurrences (final String haystack , final String needle ) {
12781283 return haystack .length () - haystack .replace (needle , "" ).length ();
12791284 }
0 commit comments