Skip to content

Commit ea582af

Browse files
committed
fix
1 parent 6d14734 commit ea582af

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ private static Throwable nettyClientSpanErrorMapper(URI uri, Throwable exception
174174
if (uri.getPath().equals("/read-timeout")) {
175175
return ReadTimeoutException.INSTANCE;
176176
}
177-
if (isNonRoutableAddress(uri) && exception instanceof ClosedChannelException) {
178-
return new PrematureChannelClosureException();
177+
if (isNonRoutableAddress(uri)) {
178+
Throwable rootCause = unwrapConnectionException(exception);
179+
if (rootCause instanceof ClosedChannelException) {
180+
return new PrematureChannelClosureException();
181+
}
182+
return rootCause;
179183
}
180184
return exception;
181185
}
@@ -200,4 +204,15 @@ private static String nettyExpectedClientSpanNameMapper(URI uri, String method)
200204
private static boolean isNonRoutableAddress(URI uri) {
201205
return "192.0.2.1".equals(uri.getHost());
202206
}
207+
208+
private static Throwable unwrapConnectionException(Throwable exception) {
209+
if (exception == null) {
210+
return null;
211+
}
212+
Throwable current = exception;
213+
while (current.getCause() != null && current.getCause() != current) {
214+
current = current.getCause();
215+
}
216+
return current;
217+
}
203218
}

0 commit comments

Comments
 (0)