@@ -93,10 +93,10 @@ public class RequestParams {
93
93
protected final static String LOG_TAG = "RequestParams" ;
94
94
protected boolean isRepeatable ;
95
95
protected boolean useJsonStreamer ;
96
- protected ConcurrentHashMap <String , String > urlParams ;
97
- protected ConcurrentHashMap <String , StreamWrapper > streamParams ;
98
- protected ConcurrentHashMap <String , FileWrapper > fileParams ;
99
- protected ConcurrentHashMap <String , Object > urlParamsWithObjects ;
96
+ protected ConcurrentHashMap <String , String > urlParams = new ConcurrentHashMap < String , String >() ;
97
+ protected ConcurrentHashMap <String , StreamWrapper > streamParams = new ConcurrentHashMap < String , StreamWrapper >() ;
98
+ protected ConcurrentHashMap <String , FileWrapper > fileParams = new ConcurrentHashMap < String , FileWrapper >() ;
99
+ protected ConcurrentHashMap <String , Object > urlParamsWithObjects = new ConcurrentHashMap < String , Object >() ;
100
100
protected String contentEncoding = HTTP .UTF_8 ;
101
101
102
102
/**
@@ -126,7 +126,6 @@ public RequestParams() {
126
126
* @param source the source key/value string map to add.
127
127
*/
128
128
public RequestParams (Map <String , String > source ) {
129
- init ();
130
129
if (source != null ) {
131
130
for (Map .Entry <String , String > entry : source .entrySet ()) {
132
131
put (entry .getKey (), entry .getValue ());
@@ -156,7 +155,6 @@ public RequestParams(final String key, final String value) {
156
155
* @throws IllegalArgumentException if the number of arguments isn't even.
157
156
*/
158
157
public RequestParams (Object ... keysAndValues ) {
159
- init ();
160
158
int len = keysAndValues .length ;
161
159
if (len % 2 != 0 )
162
160
throw new IllegalArgumentException ("Supplied arguments must be even" );
@@ -293,9 +291,9 @@ public void add(String key, String value) {
293
291
this .put (key , params );
294
292
}
295
293
if (params instanceof List ) {
296
- ((List < Object > ) params ).add (value );
294
+ ((List ) params ).add (value );
297
295
} else if (params instanceof Set ) {
298
- ((Set < Object > ) params ).add (value );
296
+ ((Set ) params ).add (value );
299
297
}
300
298
}
301
299
}
@@ -459,13 +457,6 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
459
457
return entity ;
460
458
}
461
459
462
- private void init () {
463
- urlParams = new ConcurrentHashMap <String , String >();
464
- streamParams = new ConcurrentHashMap <String , StreamWrapper >();
465
- fileParams = new ConcurrentHashMap <String , FileWrapper >();
466
- urlParamsWithObjects = new ConcurrentHashMap <String , Object >();
467
- }
468
-
469
460
protected List <BasicNameValuePair > getParamsList () {
470
461
List <BasicNameValuePair > lparams = new LinkedList <BasicNameValuePair >();
471
462
@@ -481,19 +472,21 @@ protected List<BasicNameValuePair> getParamsList() {
481
472
private List <BasicNameValuePair > getParamsList (String key , Object value ) {
482
473
List <BasicNameValuePair > params = new LinkedList <BasicNameValuePair >();
483
474
if (value instanceof Map ) {
484
- Map < String , Object > map = (Map < String , Object > ) value ;
485
- List < String > list = new ArrayList <String >(map .keySet ());
475
+ Map map = (Map ) value ;
476
+ List list = new ArrayList <Object >(map .keySet ());
486
477
// Ensure consistent ordering in query string
487
478
Collections .sort (list );
488
- for (String nestedKey : list ) {
489
- Object nestedValue = map .get (nestedKey );
490
- if (nestedValue != null ) {
491
- params .addAll (getParamsList (key == null ? nestedKey : String .format ("%s[%s]" , key , nestedKey ),
492
- nestedValue ));
479
+ for (Object nestedKey : list ) {
480
+ if (nestedKey instanceof String ) {
481
+ Object nestedValue = map .get (nestedKey );
482
+ if (nestedValue != null ) {
483
+ params .addAll (getParamsList (key == null ? (String ) nestedKey : String .format ("%s[%s]" , key , nestedKey ),
484
+ nestedValue ));
485
+ }
493
486
}
494
487
}
495
488
} else if (value instanceof List ) {
496
- List < Object > list = (List < Object > ) value ;
489
+ List list = (List ) value ;
497
490
for (Object nestedValue : list ) {
498
491
params .addAll (getParamsList (String .format ("%s[]" , key ), nestedValue ));
499
492
}
@@ -503,7 +496,7 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
503
496
params .addAll (getParamsList (String .format ("%s[]" , key ), nestedValue ));
504
497
}
505
498
} else if (value instanceof Set ) {
506
- Set < Object > set = (Set < Object > ) value ;
499
+ Set set = (Set ) value ;
507
500
for (Object nestedValue : set ) {
508
501
params .addAll (getParamsList (key , nestedValue ));
509
502
}
0 commit comments