Skip to content

Commit

Permalink
Merge branch 'master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs committed Feb 11, 2024
2 parents 7cb3925 + ef9aa23 commit 646f733
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Expand Up @@ -34,7 +34,7 @@ public final class ThreadRegistry implements Closeable {

/** Threads known to be idle uninteresting **/
public static ThreadRegistry idle() throws IOException {
return new ThreadRegistry(OS.detect().configurationDirectory().resolve("known.txt"), "known.txt");
return new ThreadRegistry(OS.detect().configurationDirectory().resolve("idle.txt"), "idle.txt");
}

/**
Expand All @@ -48,13 +48,15 @@ public static ThreadRegistry idle() throws IOException {
*/
public ThreadRegistry(Path configurationFile, String resource) throws IOException {
this.configurationFile = Objects.requireNonNull(configurationFile);
if (Files.exists(configurationFile)) {
try (Reader is = Files.newBufferedReader(configurationFile, StandardCharsets.UTF_8)) {
load(is);
}
} else {
try (InputStream is = ThreadRegistry.class.getResourceAsStream(resource)) {
load(new InputStreamReader(is, StandardCharsets.UTF_8));
try (InputStream defaultConfiguration = ThreadRegistry.class.getResourceAsStream(resource)) {
if (defaultConfiguration == null)
throw new IllegalArgumentException("Configuration " + resource + " does not exist");
if (Files.exists(configurationFile)) {
try (Reader is = Files.newBufferedReader(configurationFile, StandardCharsets.UTF_8)) {
load(is);
}
} else {
load(new InputStreamReader(defaultConfiguration, StandardCharsets.UTF_8));
}
}
}
Expand Down Expand Up @@ -100,7 +102,7 @@ public void removeAll(Stream<JavaThread> threads2) {
var tmp = threads2.collect(DISTINCT_BY_NAME);
threads.removeIf(idle -> tmp.stream().anyMatch(idle::equalByMethodName));
}

private void checkThread(JavaThread input) {
var dump = input.toString();
JavaThread parsed = JstackParser.parseThread(dump).get();
Expand Down
11 changes: 10 additions & 1 deletion pom.xml
Expand Up @@ -65,5 +65,14 @@
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
</project>

0 comments on commit 646f733

Please sign in to comment.