Issue #4747 - changes from review
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
b51a0ad458
commit
c6e58e693b
|
@ -55,7 +55,7 @@ public class CloseStatus
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
private final String reason;
|
private final String reason;
|
||||||
private Throwable cause;
|
private final Throwable cause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a reason for closing a web socket connection with the no given status code.
|
* Creates a reason for closing a web socket connection with the no given status code.
|
||||||
|
@ -211,11 +211,6 @@ public class CloseStatus
|
||||||
return !isOrdinary(code);
|
return !isOrdinary(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initCause(Throwable cause)
|
|
||||||
{
|
|
||||||
this.cause = cause;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Throwable getCause()
|
public Throwable getCause()
|
||||||
{
|
{
|
||||||
return cause;
|
return cause;
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.core.internal;
|
||||||
|
|
||||||
import java.nio.channels.ClosedChannelException;
|
import java.nio.channels.ClosedChannelException;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.websocket.core.CloseStatus;
|
import org.eclipse.jetty.websocket.core.CloseStatus;
|
||||||
import org.eclipse.jetty.websocket.core.Frame;
|
import org.eclipse.jetty.websocket.core.Frame;
|
||||||
import org.eclipse.jetty.websocket.core.OpCode;
|
import org.eclipse.jetty.websocket.core.OpCode;
|
||||||
|
@ -124,8 +125,19 @@ public class WebSocketSessionState
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should only be called directly before closing the connection when we are in {@link State#CLOSED} state.
|
* <p>
|
||||||
* This ensures an abnormal close status and if we have no error in the CloseStatus we will set one.
|
* If no error is set in the CloseStatus this will either, replace the current close status with
|
||||||
|
* a {@link CloseStatus#SERVER_ERROR} status if we had a NORMAL close code, or, it will set the cause
|
||||||
|
* of the CloseStatus if the previous cause was null, this allows onError to be notified after the connection is closed.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* This should only be called if there is an error directly before the call to
|
||||||
|
* {@link WebSocketCoreSession#closeConnection(CloseStatus, Callback)}.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* This could occur if the FrameHandler throws an exception in onFrame after receiving a close frame reply, in this
|
||||||
|
* case to notify onError we must set the cause in the closeStatus.
|
||||||
|
* </p>
|
||||||
* @param t the error which occurred.
|
* @param t the error which occurred.
|
||||||
*/
|
*/
|
||||||
public void onError(Throwable t)
|
public void onError(Throwable t)
|
||||||
|
@ -141,7 +153,7 @@ public class WebSocketSessionState
|
||||||
|
|
||||||
// Otherwise set the error if it wasn't already set to notify onError as well as onClose.
|
// Otherwise set the error if it wasn't already set to notify onError as well as onClose.
|
||||||
if (_closeStatus.getCause() == null)
|
if (_closeStatus.getCause() == null)
|
||||||
_closeStatus.initCause(t);
|
_closeStatus = new CloseStatus(_closeStatus.getCode(), _closeStatus.getReason(), t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Jetty Logging using jetty-slf4j-impl
|
# Jetty Logging using jetty-slf4j-impl
|
||||||
org.eclipse.jetty.LEVEL=INFO
|
# org.eclipse.jetty.LEVEL=DEBUG
|
||||||
# org.eclipse.jetty.io.LEVEL=DEBUG
|
# org.eclipse.jetty.io.LEVEL=DEBUG
|
||||||
# org.eclipse.jetty.websocket.core.LEVEL=DEBUG
|
# org.eclipse.jetty.websocket.core.LEVEL=DEBUG
|
||||||
# org.eclipse.jetty.websocket.core.TestFrameHandler.LEVEL=DEBUG
|
# org.eclipse.jetty.websocket.core.TestFrameHandler.LEVEL=DEBUG
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Jetty Logging using jetty-slf4j-impl
|
# Jetty Logging using jetty-slf4j-impl
|
||||||
org.eclipse.jetty.LEVEL=INFO
|
# org.eclipse.jetty.LEVEL=DEBUG
|
||||||
# org.eclipse.jetty.util.log.stderr.LONG=true
|
# org.eclipse.jetty.util.log.stderr.LONG=true
|
||||||
# org.eclipse.jetty.server.AbstractConnector.LEVEL=DEBUG
|
# org.eclipse.jetty.server.AbstractConnector.LEVEL=DEBUG
|
||||||
# org.eclipse.jetty.io.WriteFlusher.LEVEL=DEBUG
|
# org.eclipse.jetty.io.WriteFlusher.LEVEL=DEBUG
|
||||||
|
|
Loading…
Reference in New Issue