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

Un-shade docker-java-api #2882

Merged
merged 6 commits into from
Jul 9, 2020
Merged

Un-shade docker-java-api #2882

merged 6 commits into from
Jul 9, 2020

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Jun 16, 2020

This PR makes Testcontainers depend on docker-java-api instead of including it into our JAR unshaded. Note that docker-java-core and docker-java-transport-okhttp remain shaded due to their transitive dependencies like Guava or now-in-Kotlin OkHttp.

The transition requires a breaking change in the DockerClientProviderStrategy API and includes a rework.
The rework also includes an improvement that removes one Docker API call (/_ping) and instead reuses the /_info one (reduces the startup by ~200ms).

The dependency graph now looks like this:
Screenshot 2020-06-16 at 11 26 23 AM

While previously it was:
Screenshot 2020-06-16 at 11 56 32 AM

Fixes #1113

Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only had one comment, on a Javadoc change of all things 😂

rnorth added a commit to usmanovbf/testcontainers-java that referenced this pull request Jul 9, 2020
@bsideup bsideup merged commit 1c97b97 into master Jul 9, 2020
@delete-merged-branch delete-merged-branch bot deleted the unshade_docker_java_api branch July 9, 2020 15:52
@dagguh
Copy link

dagguh commented Sep 8, 2020

Note that docker-java-core and docker-java-transport-okhttp remain shaded due to their transitive dependencies like Guava or now-in-Kotlin OkHttp.

Any plans to unshade it all? I'm still getting nasty classpath clashes:

    java.lang.NoSuchMethodError: com.github.dockerjava.core.DockerClientConfig.getObjectMapper()Lorg/testcontainers/shaded/com/fasterxml/jackson/databind/ObjectMapper;
        at com.github.dockerjava.okhttp.OkHttpDockerCmdExecFactory.init(OkHttpDockerCmdExecFactory.java:124)
        at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:242)
        at org.testcontainers.dockerclient.DockerClientProviderStrategy.getClientForConfig(DockerClientProviderStrategy.java:177)
        at org.testcontainers.dockerclient.UnixSocketClientProviderStrategy.tryConfiguration(UnixSocketClientProviderStrategy.java:62)
        at org.testcontainers.dockerclient.UnixSocketClientProviderStrategy.test(UnixSocketClientProviderStrategy.java:36)
        at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$2(DockerClientProviderStrategy.java:118)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
        at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:302)
        at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:728)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findAny(ReferencePipeline.java:469)
        at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:154)
        at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:126)
        at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:147)

I need to be able to use the real DockerClientImpl and TC at the same time. So it seems that TC could either shade it without clashes (org.testcontainers.shaded.com.github.dockerjava.core) or abstain from shading entirely.

dagguh added a commit to atlassian/virtual-users that referenced this pull request Sep 8, 2020
Unblock the main API integration test.
Here's the [original rationale] for ignoring it.
In the meantime there was some progress from `testcontainers` to [reduce the class copy-paste].
This allows us to work with `docker-java-api`, which no longer clashes.
However, they're still shading `docker-java-core`, so we gotta depend on their copy for now.
Currently their copy is compatible with the rest of our code.
It's still messy, but we can stop depending on them later.

[original rationale]: 29c29fc
[reduce the class copy-paste] : testcontainers/testcontainers-java#2882
dagguh added a commit to atlassian/virtual-users that referenced this pull request Sep 9, 2020
Unblock the main API integration test.
Here's the [original rationale] for ignoring it.
In the meantime there was some progress from `testcontainers` to [reduce the class copy-paste].
This allows us to work with `docker-java-api`, which no longer clashes.
However, they're still shading `docker-java-core`, so we gotta depend on their copy for now.
Currently their copy is compatible with the rest of our code.
It's still messy, but we can stop depending on them later.

[original rationale]: 29c29fc
[reduce the class copy-paste] : testcontainers/testcontainers-java#2882
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

com.github.docker-java is not shaded and conflicts with the project's version
3 participants