1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-19 02:22:05 +01:00

Merge pull request #550 from Flowdalic/break-loop-in-webscoket-disconnect

[websocket-java11] Prevent infinite recursion in disconnect()
This commit is contained in:
Florian Schmaus 2023-02-11 15:18:29 +00:00 committed by GitHub
commit 6a90300ef6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2021 Florian Schmaus
* Copyright 2021-2023 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -139,11 +139,13 @@ public final class Java11WebSocket extends AbstractWebSocket {
@Override
public void disconnect(int code, String message) {
CompletableFuture<WebSocket> completableFuture = webSocket.sendClose(code, message);
try {
completableFuture.get();
if (!webSocket.isOutputClosed()) {
CompletableFuture<WebSocket> completableFuture = webSocket.sendClose(code, message);
completableFuture.get();
}
} catch (ExecutionException e) {
onWebSocketFailure(e);
LOGGER.log(Level.WARNING, "Failed to send final close when disconnecting " + this, e);
} catch (InterruptedException e) {
// This thread should never be interrupted, as it is a Smack internal thread.
throw new AssertionError(e);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Aditya Borikar, 2020-2021 Florian Schmaus
* Copyright 2020 Aditya Borikar, 2020-2023 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -156,4 +156,9 @@ public abstract class AbstractWebSocket {
}
public abstract SSLSession getSSLSession();
@Override
public final String toString() {
return getClass().getSimpleName() + "[" + connectionInternal.connection + "]";
}
}