Skip to content

Commit

Permalink
Drop WebSocketUpgradeHandler:: touchSuccess
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slandelle committed Feb 7, 2017
1 parent 7a70b80 commit bff695e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ public UpgradeCallback(NettyResponseFuture<?> future, Channel channel, HttpRespo
// We don't need to synchronize as replacing the "ws-decoder" will
// process using the same thread.
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) {
if (!h.touchSuccess()) {
try {
h.onSuccess(new NettyWebSocket(channel, responseHeaders.getHeaders()));
} catch (Exception ex) {
logger.warn("onSuccess unexpected exception", ex);
}
try {
h.onSuccess(new NettyWebSocket(channel, responseHeaders.getHeaders()));
} catch (Exception ex) {
logger.warn("onSuccess unexpected exception", ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class WebSocketUpgradeHandler implements UpgradeHandler<WebSocket>, Async
private WebSocket webSocket;
private final List<WebSocketListener> listeners;
private final AtomicBoolean ok = new AtomicBoolean(false);
private boolean onSuccessCalled;
private int status;
private List<Runnable> bufferedFrames;

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

public boolean touchSuccess() {
boolean prev = onSuccessCalled;
onSuccessCalled = true;
return prev;
}

@Override
public final State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
Expand Down

0 comments on commit bff695e

Please sign in to comment.