Merge pull request #4153 from eclipse/jetty-9.4.x-3558-websocket_onErrorAfterClose

Issue #3558 - only notify WS onError if onClose has not been called
This commit is contained in:
Lachlan 2019-10-10 15:27:11 +11:00 committed by GitHub
commit 00baa7147e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -41,6 +41,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConcurrentConnectTest
@ -130,7 +131,7 @@ public class ConcurrentConnectTest
assertTrue(l.closed.await(5, TimeUnit.SECONDS));
assertThat(l.closeCode, is(StatusCode.NORMAL));
assertThat(l.closeReason, is("close from client"));
//assertNull(l.failure); //TODO: we can get failures after close??
assertNull(l.failure);
}
closeListener.closeLatch.await(5, TimeUnit.SECONDS);

View File

@ -397,7 +397,10 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
}
if (openFuture != null && !openFuture.isDone())
openFuture.completeExceptionally(cause);
websocket.onError(cause);
// Only notify onError if onClose has not been called.
if (!onCloseCalled.get())
websocket.onError(cause);
}
/**