Issue
I'm encountering a strange brave/spring-cloud-sleuth issue that only occurs when testing the application in a @SpringBootTest
set up. The application makes use of a basic spring-cloud-starter-sleuth
setup, no additional configuration is used other than implementing the dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<!-- <version>3.1.1</version> (version is derived from spring-cloud-dependencies bom) -->
</dependency>
The error that pops up every now and then during a mvn clean install
:
Exception in thread "ForkJoinPool-1-worker-53" java.lang.AssertionError: Bug (or unexpected call to internal code): parent can only be null in a local root!
at brave.internal.recorder.PendingSpans.getOrCreate(PendingSpans.java:89)
at brave.Tracer._toSpan(Tracer.java:410)
at brave.Tracer.toSpan(Tracer.java:382)
at brave.Tracer.toSpan(Tracer.java:376)
at brave.LazySpan.span(LazySpan.java:141)
at brave.LazySpan.context(LazySpan.java:40)
at org.springframework.cloud.sleuth.brave.bridge.BraveSpan.context(BraveSpan.java:49)
at org.springframework.cloud.sleuth.brave.bridge.BraveTracer.nextSpan(BraveTracer.java:64)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.run(TraceRunnable.java:61)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Is anyone familiar with the stack trace above?
Solution
I found a solution almost straight after posting the question. The issue seems to be related to https://github.com/openzipkin/brave/issues/1295 . At the time of writing this post the issue has not been fixed yet.
I noticed that the error thrown is a java.lang.AssertionError
, and I have disabled assertions in the package where the error occurs until a fix has been created. By configuring the maven-surefire-plugin
and maven-failsafe-plugin
as follows the assertion can be disabled:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -da:brave.internal.recorder...</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>@{argLine} -da:brave.internal.recorder...</argLine>
</configuration>
</plugin>
Answered By - Michiel
Answer Checked By - Pedro (JavaFixing Volunteer)