Skip to content

Commit cd80847

Browse files
committed
Validating illegal argument exception when closing
1 parent c7c74ca commit cd80847

File tree

1 file changed

+7
-2
lines changed
  • opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/connectivity/websocket

1 file changed

+7
-2
lines changed

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/connectivity/websocket/OkHttpWebSocket.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ public boolean send(byte[] request) {
5252
@Override
5353
public void close(int code, @Nullable String reason) {
5454
if (status.compareAndSet(Status.RUNNING, Status.CLOSING)) {
55-
if (!getWebSocket().close(code, reason)) {
56-
status.set(Status.NOT_RUNNING);
55+
try {
56+
if (!getWebSocket().close(code, reason)) {
57+
status.set(Status.NOT_RUNNING);
58+
}
59+
} catch (IllegalArgumentException e) {
60+
status.set(Status.RUNNING);
61+
throw e;
5762
}
5863
}
5964
}

0 commit comments

Comments
 (0)