Skip to content

Commit 1b57cda

Browse files
committed
chore: additional info in exception
1 parent 2ed23c9 commit 1b57cda

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/JavaApp.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import java.io.File;
44
import java.net.InetAddress;
5+
import java.net.InetSocketAddress;
6+
import java.net.Socket;
57
import java.nio.charset.Charset;
68
import java.nio.charset.StandardCharsets;
79
import java.security.KeyStore;
10+
import java.security.Security;
811
import java.time.ZoneId;
912
import java.util.Arrays;
1013
import java.util.HexFormat;
@@ -93,5 +96,15 @@ public static void main(String[] args) throws Exception {
9396
props.size());
9497

9598
out.println(stats);
99+
100+
out.printf("%n✧✧✧✧✧ Additional info in exception ✧✧✧✧✧%n");
101+
Security.setProperty("jdk.includeInExceptions", "hostInfo,jar");
102+
try (var s = new Socket()) {
103+
s.setSoTimeout(1_00);
104+
s.connect(new InetSocketAddress("localhost", 12345), 1_00);
105+
} catch (Exception e) {
106+
out.println(e.getMessage());
107+
assert e.getMessage().contains("localhost:12345");
108+
}
96109
}
97110
}

0 commit comments

Comments
 (0)