I was using HttpClient 4.0.1 in my web application to communicate with
different servers, specifically used httpclient-4.0.1.jar,
httpcore-4.0.1.jar and httpmime-4.0.1.jar.
Everything was working without any issues.
Now I have upgraded the library to HttpClient 4.3.1 (httpclient-4.3.1.jar,
httpcore-4.3.jar & httpmime-4.3.1.jar).
I had to change my workspace code to resolve all the compilation errors
because of the library upgradation.
But when my application is trying to establish a HTTP connection with other
server, *"java.lang.ClassCastException : java.lang.Long cannot be cast to
java.lang.Integer"* is thrown from getIntParameter() method in
AbstrastHttpParams.java(part of httpcore).
Implementation of getIntParameter() is as follows :
public int getIntParameter(final String name, final int defaultValue) {
final Object param = getParameter(name);
if (param == null) {
return defaultValue;
}
return ((Integer) param).intValue();
}
When this method is invoked from HttpClientParamConfig's
setConnectionRequestTimeout() to get the value
for ClientPNames.CONN_MANAGER_TIMEOUT,
getIntParameter() throws ClassCastException because param object is
assigned with Long typed object and casting it to Integer type *reference* :
((Integer) param).intValue()
I see the following statements in ClientPNames.java
** This parameter expects a value of type {@link Long}.*
* @since 4.2
public static final String CONN_MANAGER_TIMEOUT =
"http.conn-manager.timeout";
If the parameter is of type Long, then why is setConnectionRequestTimeout()
calling getIntParameter() rather than calling getLongParameter() ?
Am I missing something here ?
Would you recommend any suggestions to resolve this issue ?
Thanks in advance,
Dhruva