Bug 59014 - No CloseMessage because of WebSocket connection has been closed
Summary: No CloseMessage because of WebSocket connection has been closed
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: 8.0.32
Hardware: PC All
: P2 major (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
: 59177 (view as bug list)
Depends on:
Reported: 2016-02-16 17:54 UTC by Artem Bilan
Modified: 2016-03-14 11:04 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Artem Bilan 2016-02-16 17:54:09 UTC
In our test-cases we would like to handle 

Endpoint.onClose(Session session, CloseReason closeReason) {}

But looks the code isn't reachable.

WsSession does:

  state = State.CLOSED_SENT;



Where we have the code like in WsRemoteEndpointImplBase.startMessageBlock:

    FutureToSendHandler f2sh = new FutureToSendHandler(wsSession);
    startMessage(opCode, payload, last, f2sh);
    try {
        if (timeout == -1) {
        } else {
            f2sh.get(timeout, TimeUnit.MILLISECONDS);

That f2sh.get() does this:



    if (isOpen()) {
         futures.put(f2sh, f2sh);

is false because our state is State.CLOSED_SENT not like:

    state == State.OPEN || state == State.SENDING_CLOSED

Therefore we never get result from that Future and our onClose() test fail.

You can find more info in the bug57489, especially https://bz.apache.org/bugzilla/show_bug.cgi?id=58624#c13 and its attachment.

The related Spring Integration JIRA: https://jira.spring.io/browse/INT-3909.

Thank you in advance!
Comment 1 Mark Thomas 2016-02-23 13:50:28 UTC
I've added the referenced test case to 9.0.x and 8.0.x. It passes with 9.0.x but not 8.0.x. I'm looking at a fix now.
Comment 2 Mark Thomas 2016-02-23 15:01:33 UTC
Fixed in 8.0.x and 7.0.x. The fix will be included in 8.0.33 and 7.0.69 onwards.
Comment 3 Artem Bilan 2016-02-23 15:16:06 UTC
Thank you, Mark, for the fix!

I would like to know if I can test it from my perspective against the 8.0.33 BUILD-SNAPSHOT.

From other side let us know when you are going to release those maintenance versions.
Comment 4 Mark Thomas 2016-02-23 15:18:36 UTC
There are no automatic snapshots although we can trigger one manually if that would be easier than you building from source.

8.0.x releases on a roughly monthly release cycle. I tend to start preparation at the start of the month with the release being generally available some time in the second week.
Comment 5 Artem Bilan 2016-02-23 15:26:11 UTC
Fair enough, Mark!

We definitely can wait for middle of March for the release. That is fully upfront in time with all our Spring release train in the May around Spring Boot 1.4.

Meanwhile I really would like to ask you about BUILD-SNAPSHOT. Not sure that check out the full Tomcat source code and build it locally would be easier for me :-).

Thank you again!
Comment 6 Mark Thomas 2016-02-23 15:39:45 UTC
It has been a while since I ran the snapshot publishing script. It is currently running and looks OK so far. Give it about 15 mins and you should have a complete 8.0.x snapshot of the current trunk under:

Let us know how you get on with it.
Comment 8 Violeta Georgieva 2016-03-14 11:04:02 UTC
*** Bug 59177 has been marked as a duplicate of this bug. ***