testcontainers / testcontainers/testcontainers-java

NullPointerException in old shaded OkHttp version

Open
#3,535 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Hi

We're getting occasional flaky tests when using testcontainers-java which has an embedded docker-java-transport-okhttp shaded in its jar.

Could not start container
java.lang.NullPointerException
  at org.testcontainers.shaded.okio.Okio$1.write(Okio.java:78)
  at org.testcontainers.shaded.okio.AsyncTimeout$1.write(AsyncTimeout.java:180)
  at org.testcontainers.shaded.okio.RealBufferedSink.flush(RealBufferedSink.java:224)
  at org.testcontainers.shaded.okhttp3.internal.http1.Http1ExchangeCodec.finishRequest(Http1ExchangeCodec.java:190)
  at org.testcontainers.shaded.okhttp3.internal.connection.Exchange.finishRequest(Exchange.java:101)
  at org.testcontainers.shaded.okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:86)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
  at org.testcontainers.shaded.com.github.dockerjava.okhttp.HijackingInterceptor.intercept(HijackingInterceptor.java:20)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
  at org.testcontainers.shaded.okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
  at org.testcontainers.shaded.okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
  at org.testcontainers.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
  at org.testcontainers.shaded.okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
  at org.testcontainers.shaded.okhttp3.RealCall.execute(RealCall.java:81)
  at org.testcontainers.shaded.com.github.dockerjava.okhttp.OkDockerHttpClient$OkResponse.<init>(OkDockerHttpClient.java:251)
  at org.testcontainers.shaded.com.github.dockerjava.okhttp.OkDockerHttpClient.execute(OkDockerHttpClient.java:225)
  at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
  at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:125)
  at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:33)
  at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
  at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
  at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
  at org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:595)
  at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:404)
  at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:322)
  at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
  at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:320)
  at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:308)
  at org.testcontainers.lifecycle.Startable$start.call(Unknown Source)

docker-java-transport-okhttp currently depends on OkHttp 3.14.4, but there have been many releases since: they're up to 4.9.0 and the code in question has changed somewhat, presumably fixing bugs. I've raised https://github.com/docker-java/docker-java/issues/1507 there to suggest bumping the issue, but it's difficult to test whether the latest version still has the bug since the dependency is shaded.

It would be good to have a non-shaded library that would allow your users to bump versions if they need to in situations like this. It might also be good to bump the OkHttp version if upstream doesn't do it soon.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the flaky Testcontainers container-start failure and the shaded docker-java-transport-okhttp dependency, then review the linked docker-java issue 1507 and the OkHttp 3.14.4 stack trace. Done means establishing whether the NPE is resolved by an upstream version change or requires a supported non-shaded dependency path.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
testing
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.