Skip to content

Commit 3d8f066

Browse files
committed
Fix connectionErrorUnopenedPortWithCallback
1 parent 984439e commit 3d8f066

File tree

2 files changed

+20
-7
lines changed
  • instrumentation/play/play-mvc/play-mvc-2.4/javaagent/src

2 files changed

+20
-7
lines changed

instrumentation/play/play-mvc/play-mvc-2.4/javaagent/src/play24Test/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/client/PlayWsClientTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ public void sendRequestWithCallback(
6262
internalSendRequest(wsRequest, method)
6363
.whenComplete(
6464
(wsResponse, throwable) -> {
65-
httpClientResult.complete(wsResponse::getStatus, throwable);
65+
if (wsResponse != null) {
66+
httpClientResult.complete(wsResponse::getStatus, throwable);
67+
} else {
68+
httpClientResult.complete(
69+
() -> {
70+
throw new IllegalArgumentException("wsResponse is null!", throwable);
71+
},
72+
throwable);
73+
}
6674
});
6775
}
6876

@@ -78,8 +86,7 @@ protected void configure(HttpClientTestOptions.Builder optionsBuilder) {
7886
return attributes;
7987
});
8088

81-
optionsBuilder.setTestConnectionFailure(false);
82-
optionsBuilder.setSpanEndsAfterType(null);
89+
optionsBuilder.spanEndsAfterBody();
8390

8491
// Play HTTP client uses AsyncHttpClient internally which does not support HTTP 1.1 pipelining
8592
// nor waiting for connection pool slots to free up. Therefore making a single connection test

instrumentation/play/play-mvc/play-mvc-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/client/PlayWsClientTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,23 @@ public void sendRequestWithCallback(
5858
internalSendRequest(wsRequest, method)
5959
.whenComplete(
6060
(wsResponse, throwable) -> {
61-
httpClientResult.complete(wsResponse::getStatus, throwable);
61+
if (wsResponse != null) {
62+
httpClientResult.complete(wsResponse::getStatus, throwable);
63+
} else {
64+
httpClientResult.complete(
65+
() -> {
66+
throw new IllegalArgumentException("wsResponse is null!", throwable);
67+
},
68+
throwable);
69+
}
6270
});
6371
}
6472

6573
@Override
6674
protected void configure(HttpClientTestOptions.Builder optionsBuilder) {
6775
optionsBuilder.setTestRedirects(false);
6876
optionsBuilder.setTestReadTimeout(false);
69-
70-
optionsBuilder.setTestConnectionFailure(false);
71-
optionsBuilder.setSpanEndsAfterType(null);
77+
optionsBuilder.spanEndsAfterBody();
7278

7379
// Play HTTP client uses AsyncHttpClient internally which does not support HTTP 1.1 pipelining
7480
// nor waiting for connection pool slots to free up. Therefore making a single connection test

0 commit comments

Comments
 (0)