Skip to content

Commit 7516b37

Browse files
committed
chore: logging
1 parent 044a96e commit 7516b37

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

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

8-
import java.io.InputStream;
8+
import java.net.HttpURLConnection;
99
import java.net.URL;
1010
import java.util.Map;
1111
import java.util.concurrent.Executor;
@@ -22,9 +22,6 @@ public static void main(String[] args) throws Exception {
2222
executeDemos();
2323
Thread.sleep(1000);
2424

25-
int threadCount = Thread.activeCount();
26-
System.out.println("Thread count: " + threadCount);
27-
2825
Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
2926
for (Map.Entry<Thread, StackTraceElement[]> entry : threads.entrySet()) {
3027
Thread thread = entry.getKey();
@@ -34,6 +31,9 @@ public static void main(String[] args) throws Exception {
3431
System.out.println(" " + stackTraceElement);
3532
}
3633
}
34+
35+
int threadCount = Thread.activeCount();
36+
System.out.println("Thread count: " + threadCount);
3737
}
3838
}
3939

@@ -94,9 +94,12 @@ public static void triggerEndpoints() {
9494
private static void callEndpoint(String endpoint) {
9595
executor.execute(() -> {
9696
try {
97-
//noinspection EmptyTryBlock
98-
try (InputStream ignore = new URL("http://localhost:8080" + endpoint).openStream()) {
99-
}
97+
URL url = new URL("http://localhost:8080" + endpoint);
98+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
99+
connection.setConnectTimeout(5000);
100+
connection.setReadTimeout(5000);
101+
connection.getResponseCode();
102+
connection.disconnect();
100103
} catch (Exception ignore) {
101104
}
102105
});

0 commit comments

Comments
 (0)