Issue #2175 cleanups after review

Improve ws error handling by splitting processError into handling for
errors from the network and errors from the application.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-01-22 13:36:09 +11:00
parent 05dfbd18cd
commit 1189ceed4c
2 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.websocket.core.internal; package org.eclipse.jetty.websocket.core.internal;
import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
@ -74,6 +75,18 @@ public class FrameFlusher extends IteratingCallback
} }
} }
public void onClose()
{
Throwable cause = null;
synchronized (this)
{
if (!queue.isEmpty())
cause = new IOException("Closed");
}
if (cause!=null)
onCompleteFailure(cause);
}
@Override @Override
protected Action process() throws Throwable protected Action process() throws Throwable
{ {

View File

@ -172,10 +172,12 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
IOException e = new IOException("Closed"); IOException e = new IOException("Closed");
channel.onClosed(e); channel.onClosed(e);
} }
flusher.onClose();
super.onClose(); super.onClose();
} }
@Override @Override
public boolean onIdleExpired() public boolean onIdleExpired()
{ {