Bug 1255078 - Don't use deprecated DefaultHttpClient as it causes backwards compatibility problems
Don't use deprecated DefaultHttpClient as it causes backwards compatibility p...
Status: CLOSED CURRENTRELEASE
Product: ovirt-engine-sdk-java
Classification: oVirt
Component: General (Show other bugs)
---
Unspecified Unspecified
unspecified Severity medium (vote)
: ovirt-3.6.0-rc
: 3.6.0.0
Assigned To: Juan Hernández
Gonza
infra
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-19 10:45 EDT by Juan Hernández
Modified: 2016-02-10 14:14 EST (History)
8 users (show)

See Also:
Fixed In Version: ovirt-engine-sdk-java-3.6.0.0-0.17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-13 09:40:20 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Infra
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: ovirt‑3.6.0+
ylavi: planning_ack+
rule-engine: devel_ack+
rule-engine: testing_ack+


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 45102 master MERGED sdk: Don't call DefaultHttpClient.execute Never
oVirt gerrit 45161 sdk_3.6 MERGED sdk: Don't call DefaultHttpClient.execute Never

  None (edit)
Description Juan Hernández 2015-08-19 10:45:21 EDT
Currently the Java SDK uses the HttpComponents DefaultHttpClient class. In version 4.3 of HttpComponents this class has been marked as deprecated, and it inheritance hierarchy has been changed so that the it extends the new CloseableHttpClient class. One side effect of this changes is that the "execute" method has changed its signature from this:

  HttpResponse execute(HttpUriRequest, HttpContext)

To this:

  CloseableHttpResponse execute(HttpUriRequest, HttpContext)

This doesn't cause a problem for existing compiled .class or .jar files that use that class, because the new CloseableHttpResponse class is compatible with HttpResponse. But it causes a problem when the client is recompiled from source. For example, consider this code (which is part of the Java SDK):

  DefaultHttpClient client = ...;
  client.execute(request, context);

With version 4.2 of HttpComponents compiling this code results in the following binary code:

  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;

With version 4.3 of HttpComponents it results in the following binary code:

  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 4.2 returns HttpResponse and 4.3 returns CloseableHttpResponse.

This new binary will work correctly with version 4.3 of HttpComponents, but it will fail with the following error with version 3.2 of HttpComponents:

  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;
Comment 1 Red Hat Bugzilla Rules Engine 2015-10-18 04:34:51 EDT
Bug tickets that are moved to testing must have target release set to make sure tester knows what to test. Please set the correct target release before moving to ON_QA.
Comment 2 Juan Hernández 2016-01-07 10:30:06 EST
Note that in this comment I should have written 4.2, not 3.2:

---8<---
This new binary will work correctly with version 4.3 of HttpComponents, but it will fail with the following error with version 3.2 of HttpComponents:
--->8---

Version 3.2 of httpcomponents isn't supported or used by the SDK.
Comment 3 Gonza 2016-01-07 10:49:35 EST
Verified with:
ovirt-engine-sdk-java-4.0.0.0-0.1.20151127.git7c24cff.fc22.noarch

Successfully built the java sdk with versions 4.2 and 4.3 of HttpComponents.
Comment 4 Sandro Bonazzola 2016-01-13 09:40:20 EST
oVirt 3.6.0 has been released, closing current release

Note You need to log in before you can comment on or make changes to this bug.