Skip to content

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

@HelloCoCooo

Description

@HelloCoCooo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions