Skip to content

Commit bff695e

Browse files
committed
Drop WebSocketUpgradeHandler:: touchSuccess
Motivation This hack was a very old workaround for #317 where the server would send the first frame along with the handshake. This issue has actually been fixed for quite some time, we just had to replace the `UpgradeCallback` with the future before triggering the read when upgrading the pipeline. We no longer need this protection as there’s no way the `UpgradeCallback` can be called twice. Modification: Remove dead code. Result: Clean code
1 parent 7a70b80 commit bff695e

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

client/src/main/java/org/asynchttpclient/netty/handler/WebSocketHandler.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ public UpgradeCallback(NettyResponseFuture<?> future, Channel channel, HttpRespo
7373
// We don't need to synchronize as replacing the "ws-decoder" will
7474
// process using the same thread.
7575
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) {
76-
if (!h.touchSuccess()) {
77-
try {
78-
h.onSuccess(new NettyWebSocket(channel, responseHeaders.getHeaders()));
79-
} catch (Exception ex) {
80-
logger.warn("onSuccess unexpected exception", ex);
81-
}
76+
try {
77+
h.onSuccess(new NettyWebSocket(channel, responseHeaders.getHeaders()));
78+
} catch (Exception ex) {
79+
logger.warn("onSuccess unexpected exception", ex);
8280
}
8381
}
8482

client/src/main/java/org/asynchttpclient/ws/WebSocketUpgradeHandler.java

-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class WebSocketUpgradeHandler implements UpgradeHandler<WebSocket>, Async
3333
private WebSocket webSocket;
3434
private final List<WebSocketListener> listeners;
3535
private final AtomicBoolean ok = new AtomicBoolean(false);
36-
private boolean onSuccessCalled;
3736
private int status;
3837
private List<Runnable> bufferedFrames;
3938

@@ -53,11 +52,6 @@ public final void onThrowable(Throwable t) {
5352
onFailure(t);
5453
}
5554

56-
public boolean touchSuccess() {
57-
boolean prev = onSuccessCalled;
58-
onSuccessCalled = true;
59-
return prev;
60-
}
6155

6256
@Override
6357
public final State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {

0 commit comments

Comments
 (0)