Bug 1255078 - Don't use deprecated DefaultHttpClient as it causes backwards compatibility problems
Summary: Don't use deprecated DefaultHttpClient as it causes backwards compatibility p...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine-sdk-java
Classification: oVirt
Component: General
Version: ---
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-3.6.0-rc
: 3.6.0.0
Assignee: Juan Hernández
QA Contact: Gonza
URL:
Whiteboard: infra
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-19 14:45 UTC by Juan Hernández
Modified: 2016-02-10 19:14 UTC (History)
8 users (show)

Fixed In Version: ovirt-engine-sdk-java-3.6.0.0-0.17
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-01-13 14:40:20 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-3.6.0+
ylavi: planning_ack+
rule-engine: devel_ack+
rule-engine: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 45102 0 master MERGED sdk: Don't call DefaultHttpClient.execute Never
oVirt gerrit 45161 0 sdk_3.6 MERGED sdk: Don't call DefaultHttpClient.execute Never

Description Juan Hernández 2015-08-19 14:45:21 UTC
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 08:34:51 UTC
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 15:30:06 UTC
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 15:49:35 UTC
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 14:40:20 UTC
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.