Skip to content

Commit c072939

Browse files
authored
Socket.connect may throw other exceptions, such as SecurityException (#10337)
1 parent a5ae975 commit c072939

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,17 @@ public void toJson(JsonWriter writer, Config config) throws IOException {
162162
}
163163

164164
private static boolean agentServiceCheck(Config config) {
165-
if (config.getAgentUrl().startsWith("unix:")) {
166-
return new File(config.getAgentUnixDomainSocket()).exists();
167-
} else {
168-
try (Socket s = new Socket()) {
169-
s.connect(new InetSocketAddress(config.getAgentHost(), config.getAgentPort()), 500);
170-
return true;
171-
} catch (IOException ex) {
172-
return false;
165+
try {
166+
if (config.getAgentUrl().startsWith("unix:")) {
167+
return new File(config.getAgentUnixDomainSocket()).exists();
168+
} else {
169+
try (Socket s = new Socket()) {
170+
s.connect(new InetSocketAddress(config.getAgentHost(), config.getAgentPort()), 500);
171+
return true;
172+
}
173173
}
174+
} catch (Throwable ex) {
175+
return false;
174176
}
175177
}
176178

0 commit comments

Comments
 (0)