Change in ovirt-engine-sdk-java[sdk_3.6]: sdk: Don't call DefaultHttpClient.execute
juan.hernandez at redhat.com
juan.hernandez at redhat.com
Thu Aug 20 17:06:52 UTC 2015
Juan Hernandez has submitted this change and it was merged.
Change subject: sdk: Don't call DefaultHttpClient.execute
......................................................................
sdk: Don't call DefaultHttpClient.execute
Thte DefaultHttpClient class has been deprecated in version 4.3 of
HttpCoponents, and the "execute" method signature has changed from this:
HttpResponse execute(HttpUriRequest, HttpContext)
To this:
CloseableHttpResponse execute(HttpUriRequest, HttpContext)
This means that the result of compiling calls to this method depends on
the version of HttpComponents used during the build. When using version
4.2 or older the result is this:
invokevirtual #14 // Method
org/apache/http/impl/client/DefaultHttpClient.execute:(
Lorg/apache/http/client/methods/HttpUriRequest;
Lorg/apache/http/protocol/HttpContext;
)Lorg/apache/http/HttpResponse;
When using version 4.3 or newer the result is this:
invokevirtual #14 // Method
org/apache/http/impl/client/DefaultHttpClient.execute:(
Lorg/apache/http/client/methods/HttpUriRequest;
Lorg/apache/http/protocol/HttpContext;
)Lorg/apache/http/client/methods/CloseableHttpResponse;
Note that with 4.2 the return type is "HttpResponse" but with 4.3 the
return type is "CloseableHttpResponse".
This shouldn't be a problem when building with maven, as we explicitly
specify version 4.2 in the POM of the project, but it can be a problem
in other build environments that don't use maven.
When built with the newer HttpComponents version execution will fail if
the older version is used, with the following error message:
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.http.impl.client.DefaultHttpClient.execute(
Lorg/apache/http/client/methods/HttpUriRequest;
Lorg/apache/http/protocol/HttpContext;
)Lorg/apache/http/client/methods/CloseableHttpResponse;
The right solution to this problem is to modify the SDK so that it
doesn't use the deprecated "DefaultHttpClient" class at all, but this
requires many changes. Instead of that this patch changes the SDK
minimally, so that the "DefaultHttpClient" class is used, but not for
calling the "execute" method, the "HttpClient" interface is used for
that instead. This way the result of compiling the calls to "execute" is
the same regardless of the version used. The changes required to stop
using "DefaultHttpClient" will be included in other patches.
Change-Id: I06f99256566f67034bbeff843eaf959cf4a87760
Bug-Url: https://bugzilla.redhat.com/1255078
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
(cherry picked from commit f970761625ab6e5ff146259a3910315e6823228b)
---
M sdk/Makefile
M sdk/src/main/java/org/ovirt/engine/sdk/web/ConnectionsPool.java
2 files changed, 5 insertions(+), 4 deletions(-)
Approvals:
Juan Hernandez: Verified; Looks good to me, approved; Passed CI tests
--
To view, visit https://gerrit.ovirt.org/45161
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I06f99256566f67034bbeff843eaf959cf4a87760
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: sdk_3.6
Gerrit-Owner: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
More information about the Engine-commits
mailing list