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:
commit
6a90300ef6
2 changed files with 12 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue