Skip to content

Commit 044a96e

Browse files
committed
chore: logging
1 parent 1aa9d55 commit 044a96e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/main/java/spp/demo/Main.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import spp.demo.command.AddLog;
66
import spp.demo.command.TailLogs;
77

8+
import java.io.InputStream;
89
import java.net.URL;
10+
import java.util.Map;
911
import java.util.concurrent.Executor;
1012
import java.util.concurrent.Executors;
1113

@@ -22,6 +24,16 @@ public static void main(String[] args) throws Exception {
2224

2325
int threadCount = Thread.activeCount();
2426
System.out.println("Thread count: " + threadCount);
27+
28+
Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
29+
for (Map.Entry<Thread, StackTraceElement[]> entry : threads.entrySet()) {
30+
Thread thread = entry.getKey();
31+
StackTraceElement[] stackTraceElements = entry.getValue();
32+
System.out.println("Thread: " + thread.getName());
33+
for (StackTraceElement stackTraceElement : stackTraceElements) {
34+
System.out.println(" " + stackTraceElement);
35+
}
36+
}
2537
}
2638
}
2739

@@ -82,9 +94,9 @@ public static void triggerEndpoints() {
8294
private static void callEndpoint(String endpoint) {
8395
executor.execute(() -> {
8496
try {
85-
System.out.println("Calling endpoint: " + endpoint);
86-
new URL("http://localhost:8080" + endpoint).openStream().close();
87-
System.out.println("Called endpoint: " + endpoint);
97+
//noinspection EmptyTryBlock
98+
try (InputStream ignore = new URL("http://localhost:8080" + endpoint).openStream()) {
99+
}
88100
} catch (Exception ignore) {
89101
}
90102
});

0 commit comments

Comments
 (0)