hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastiaan van Erk <sebs...@sebster.com>
Subject generics issue in httpclient 4.0-alpha4
Date Sat, 10 May 2008 09:03:58 GMT

First of all, thanks for the new httpclient release. :-)

When I was updating my project I ran into one small generics issue; the 
following code will not compile:

	new UrlEncodedFormEntity(Collections.singletonList(new 
BasicNameValuePair("a", "b")));

because UrlEncodedFormEntity wants a List<NameValuePair> and the above 
code results in a List<BasicNameValuePair>. Considering that the list is 
probably read only in the httpclient code, the declaration of the 
UrlEncodedFormEntity constructor could be changed to:

     public UrlEncodedFormEntity (
         final List <? extends NameValuePair> parameters,
         final String encoding) throws UnsupportedEncodingException {
         super(URLEncodedUtils.format(parameters, encoding),

(note the List<? extends NameValuePair>).


View raw message