-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: intermitent error on multithread (#70)
- Loading branch information
Orlando Krause
committed
Jul 17, 2024
1 parent
c79e21a
commit c580177
Showing
3 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
async-profiler-context/src/test/java/io/pyroscope/labels/ScopedContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.pyroscope.labels; | ||
|
||
import io.pyroscope.labels.io.pyroscope.PyroscopeAsyncProfiler; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
public class ScopedContextTest { | ||
|
||
static { | ||
PyroscopeAsyncProfiler.getAsyncProfiler(); | ||
} | ||
|
||
|
||
/** | ||
* This test demonstrates the issue reported <a href="https://github.com/grafana/pyroscope-java/issues/70">here</a> | ||
*/ | ||
@Test | ||
void closeContextOnOtherThread() throws ExecutionException, InterruptedException { | ||
ExecutorService executorService = Executors.newFixedThreadPool(1); | ||
ScopedContext context = new ScopedContext(new LabelsSet("k1", "v1")); | ||
executorService.submit(context::close).get(); | ||
Pyroscope.LabelsWrapper.dump(); | ||
new ScopedContext(new LabelsSet("k1", "v1")); | ||
} | ||
} |