Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ enum Scope {
* <p>Annotations are collected hierarchically from the class and its superclasses, and the
* filters from all levels are combined.
*
* <p>The default value of this annotation is {@link SystemThreadFilter} which excludes many known
* system and other ignorable threads. Add this filter explicitly when you redeclare the
* exclusions or omit it if you'd like to detect those system threads.
*
* @see SystemThreadFilter
*/
@Target({ElementType.TYPE})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ public boolean test(Thread t) {
return true;
}

// These are some of the "known" threads that should be ignored.
var tName = t.getName();

// Intellij Idea attaches to forked test processes using jmx/rmi. This is asynchronous and
// unpredictable.
if (Boolean.getBoolean("intellij.debug.agent")) {
// JMX server connection timeout
if (tName.startsWith("JMX server connection timeout") || tName.startsWith("RMI TCP")) {
return true;
}
}

// These are some of the "known" threads that should be ignored.
return switch (tName) {
case "JFR request timer",
"YJPAgent-Telemetry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.*;

import com.carrotsearch.randomizedtesting.jupiter.DetectThreadLeaks;
import com.carrotsearch.randomizedtesting.jupiter.Randomized;
import com.carrotsearch.randomizedtesting.jupiter.SystemThreadFilter;
import com.carrotsearch.randomizedtesting.tests.infra.IgnoreInStandaloneRuns;
import java.time.Duration;
import java.util.ArrayList;
Expand Down Expand Up @@ -387,6 +389,25 @@ void testMethod() {
}
}

@Test
void intellijJmxThreads() {
collectExecutionResults(testKitBuilder(IntellijThreads.class))
.results()
.allEvents()
.assertThatEvents()
.doNotHave(event(finishedWithFailure()));
}

@DetectThreadLeaks(scope = DetectThreadLeaks.Scope.SUITE)
@DetectThreadLeaks.ExcludeThreads(value = {SystemThreadFilter.class})
@Randomized
static class IntellijThreads { // extends IgnoreInStandaloneRuns {
@Test
void testMethod() throws Exception {
Thread.sleep(1000);
}
}

@DetectThreadLeaks(scope = DetectThreadLeaks.Scope.SUITE)
@DetectThreadLeaks.ExcludeThreads(ExcludeNamedAFilter.class)
static class ExcludedByClassFilter extends IgnoreInStandaloneRuns {
Expand Down
Loading