Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency conflicts on org.apache.httpcomponents:httpcore:jar, leading to invoking unexpected method #364

Open
HelloCoCooo opened this issue Jan 25, 2019 · 3 comments

Comments

@HelloCoCooo
Copy link

Hi, there are multiple versions of org.apache.httpcomponents:httpcore:jar: in Hydra-0.4.5. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only org.apache.httpcomponents:httpcore:jar:4.1 can be loaded, and org.apache.httpcomponents:httpcore:jar:4.2.1 will be shadowed.

As org.apache.httpcomponents:httpcore:jar:4.2.1 is missing during the build process, method com.findwise.hydra.input.HttpInputServer.init() actually references method org.apache.http.impl.DefaultConnectionReuseStrategy.keepAlive(HttpResponse, HttpContext) in the unexpected version org.apache.httpcomponents:httpcore:jar:4.1 via the following invocation path:

<com.findwise.hydra.input.HttpInputServer: void init()> <org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor: void execute(org.apache.http.nio.reactor.IOEventDispatch)> <junit.extensions.ActiveTestSuite$1: void run()> <junit.framework.JUnit4TestAdapter: void run(junit.framework.TestResult)> <org.junit.internal.runners.JUnit4ClassRunner: void run(org.junit.runner.notification.RunNotifier)> <org.junit.internal.runners.ClassRoadie: void runProtected()> <org.junit.internal.runners.ClassRoadie: void runUnprotected()> <org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker: void run()> <org.apache.http.impl.nio.reactor.BaseIOReactor: void execute(org.apache.http.nio.reactor.IOEventDispatch)> <org.apache.http.impl.nio.reactor.AbstractIOReactor: void execute()> <org.apache.http.impl.nio.reactor.BaseIOReactor: void validate(java.util.Set)> <org.apache.http.impl.nio.SSLClientIOEventDispatch: void inputReady(org.apache.http.nio.reactor.IOSession)> <org.apache.http.impl.nio.DefaultNHttpClientConnection: void consumeInput(org.apache.http.nio.NHttpClientHandler)> <org.apache.http.nio.protocol.ThrottlingHttpClientHandler: void inputReady(org.apache.http.nio.NHttpClientConnection,org.apache.http.nio.ContentDecoder)> <org.apache.http.impl.DefaultConnectionReuseStrategy: boolean keepAlive(org.apache.http.HttpResponse,org.apache.http.protocol.HttpContext)>

By further analyzing, the expected callee org.apache.http.impl.DefaultConnectionReuseStrategy.keepAlive(HttpResponse, HttpContext) in shadowed version httpcore:jar:4.2.1, have different implementations from the actual callees with the same signatures (same method names, same paremeters) included in the unexpected (but actual loaded) version httpcore:jar:4.1, which leads to different behaviors.

Solution:
Use version httpcore:jar:4.2.1 to keep the version consistency.

Dependency tree-----------
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ hydra-input-server ---
[INFO] com.findwise.hydra:hydra-input-server:jar:0.4.5
[INFO] +- com.findwise.hydra:hydra-api:jar:0.4.5:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile
[INFO] | | +- (org.apache.httpcomponents:httpcore:jar:4.2.1:compile - omitted for conflict with 4.1)
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | - commons-codec:commons-codec:jar:1.6:compile
[INFO] | +- com.google.code.gson:gson:jar:1.7.1:compile
[INFO] | - ch.qos.logback:logback-classic:jar:1.0.10:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.0.10:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] +- org.apache.httpcomponents:httpcore-nio:jar:4.1:compile
[INFO] | - org.apache.httpcomponents:httpcore:jar:4.1:compile
[INFO] - junit:junit:jar:4.11:test
[INFO] - org.hamcrest:hamcrest-core:jar:1.3:test

Best regards,
Coco

@HelloCoCooo
Copy link
Author

HelloCoCooo commented Jan 25, 2019

Code snippet of <org.apache.http.impl.DefaultConnectionReuseStrategy: boolean keepAlive(org.apache.http.HttpResponse,org.apache.http.protocol.HttpContext)> in httpcore:jar:4.1:
keepalive4 1

Code snippet of <org.apache.http.impl.DefaultConnectionReuseStrategy: boolean keepAlive(org.apache.http.HttpResponse,org.apache.http.protocol.HttpContext)> in httpcore:jar:4.2.1:
keepalive4 2 1

Method keepAlive(HttpResponse, HttpContext) included in httpcore:jar:4.2.1 and httpcore:jar:4.1 have different implementation (different control flows and data flows), which leads to unexpected behaviors.

Using the following test case to run on these two versions of methods respectively starting from the entry method javax.swing.ProgressMonitorInputStream.ProgressMonitorInputStream(component, object, InputStream) in your project, then we can find that states of variable connStrategy in object DefaultConnectionReuseStrategy are changed, which will affect the behaviors of method DefaultConnectionReuseStrategy.keepAlive and ThrottlingHttpClientHandler.inputReady
Hydra_test.txt

Please check whether the changes of this variable value will affect your semantic behaviors.

@ebbesson
Copy link
Contributor

This project is no longer being maintained @HelloCoCooo

@ebbesson
Copy link
Contributor

Hi, please create a PR and we'll have a look at it or what do you say @jwestberg @ssimon @laserval?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants