prefer the field and variable name of coreSession instead of session

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2019-05-22 10:22:26 +10:00 committed by Greg Wilkins
parent 491ff5eb93
commit f4990dd0f5
32 changed files with 138 additions and 138 deletions

View File

@ -51,7 +51,7 @@ public abstract class AbstractJavaxWebSocketFrameHandlerTest
protected AvailableDecoders decoders;
protected Map<String, String> uriParams;
protected EndpointConfig endpointConfig;
protected FrameHandler.CoreSession session = new FrameHandler.CoreSession.Empty();
protected FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty();
public AbstractJavaxWebSocketFrameHandlerTest()
{

View File

@ -45,7 +45,7 @@ public class JavaxWebSocketFrameHandler_OnCloseTest extends AbstractJavaxWebSock
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// These invocations are the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
CloseStatus status = new CloseStatus(CloseStatus.NORMAL, "Normal");
Frame closeFrame = status.toFrame();
localEndpoint.onFrame(closeFrame, Callback.from(() ->

View File

@ -42,7 +42,7 @@ public class JavaxWebSocketFrameHandler_OnErrorTest extends AbstractJavaxWebSock
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// These invocations are the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
localEndpoint.onError(new RuntimeException("From Testcase"), Callback.NOOP);
String event = socket.events.poll(1, TimeUnit.SECONDS);
assertThat("Event", event, eventMatcher);

View File

@ -45,7 +45,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_BinaryStreamTest extends Abstr
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// This invocation is the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
func.apply(localEndpoint);

View File

@ -48,7 +48,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_BinaryTest extends AbstractJav
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// This invocation is the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
assertThat("Has Binary Metadata", localEndpoint.getBinaryMetadata(), notNullValue());

View File

@ -44,7 +44,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_TextStreamTest extends Abstrac
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// This invocation is the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
func.apply(localEndpoint);

View File

@ -47,7 +47,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_TextTest extends AbstractJavax
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// This invocation is the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
ByteBuffer payload = BufferUtil.toBuffer(msg, StandardCharsets.UTF_8);
localEndpoint.onFrame(new Frame(OpCode.TEXT).setPayload(payload).setFin(true), Callback.NOOP);

View File

@ -40,7 +40,7 @@ public class JavaxWebSocketFrameHandler_OnOpenTest extends AbstractJavaxWebSocke
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
// This invocation is the same for all tests
localEndpoint.onOpen(session, Callback.NOOP);
localEndpoint.onOpen(coreSession, Callback.NOOP);
String event = socket.events.poll(1, TimeUnit.SECONDS);
assertThat("Event", event, eventMatcher);
}

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.websocket.javax.tests;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.function.Function;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.server.Server;
@ -35,11 +40,6 @@ import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler;
import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameEcho;
import org.eclipse.jetty.websocket.javax.tests.framehandlers.WholeMessageEcho;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.function.Function;
public class CoreServer extends ContainerLifeCycle
{
private Server server;
@ -121,7 +121,7 @@ public class CoreServer extends ContainerLifeCycle
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
}
@ -178,7 +178,7 @@ public class CoreServer extends ContainerLifeCycle
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
}
}

View File

@ -156,7 +156,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
{
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
{
frameCapture.session.sendFrame(f, blocker, false);
frameCapture.coreSession.sendFrame(f, blocker, false);
}
}
}
@ -168,7 +168,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
{
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
{
frameCapture.session.sendFrame(f, blocker, false);
frameCapture.coreSession.sendFrame(f, blocker, false);
}
}
}
@ -222,7 +222,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
private final BlockingQueue<Frame> receivedFrames = new LinkedBlockingQueue<>();
private final EndPoint endPoint;
private final SharedBlockingCallback blockingCallback = new SharedBlockingCallback();
private CoreSession session;
private CoreSession coreSession;
public FrameCapture(EndPoint endPoint)
{
@ -233,7 +233,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
@Override
public void onOpen(CoreSession coreSession, Callback callback)
{
this.session = coreSession;
this.coreSession = coreSession;
callback.succeeded();
}

View File

@ -34,7 +34,7 @@ public abstract class AbstractExtension implements Extension
private ExtensionConfig config;
private OutgoingFrames nextOutgoing;
private IncomingFrames nextIncoming;
private WebSocketCoreSession session;
private WebSocketCoreSession coreSession;
public AbstractExtension()
{
@ -141,14 +141,14 @@ public abstract class AbstractExtension implements Extension
}
@Override
public void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession)
public void setWebSocketCoreSession(WebSocketCoreSession coreSession)
{
session = webSocketCoreSession;
this.coreSession = coreSession;
}
protected WebSocketCoreSession getWebSocketCoreSession()
{
return session;
return coreSession;
}
@Override

View File

@ -91,7 +91,7 @@ public interface Extension extends IncomingFrames, OutgoingFrames
/**
* Set the {@link WebSocketCoreSession} for this Extension
*
* @param webSocketCoreSession
* @param coreSession
*/
void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession);
void setWebSocketCoreSession(WebSocketCoreSession coreSession);
}

View File

@ -516,7 +516,7 @@ public interface FrameHandler extends IncomingFrames
interface Customizer
{
void customize(CoreSession session);
void customize(CoreSession coreSession);
}
class ConfigurationCustomizer implements Customizer, Configuration
@ -627,24 +627,24 @@ public interface FrameHandler extends IncomingFrames
}
@Override
public void customize(CoreSession session)
public void customize(CoreSession coreSession)
{
if (idleTimeout !=null)
session.setIdleTimeout(idleTimeout);
coreSession.setIdleTimeout(idleTimeout);
if (writeTimeout!=null)
session.setWriteTimeout(idleTimeout);
coreSession.setWriteTimeout(idleTimeout);
if (autoFragment!=null)
session.setAutoFragment(autoFragment);
coreSession.setAutoFragment(autoFragment);
if (maxFrameSize!=null)
session.setMaxFrameSize(maxFrameSize);
coreSession.setMaxFrameSize(maxFrameSize);
if (inputBufferSize!=null)
session.setInputBufferSize(inputBufferSize);
coreSession.setInputBufferSize(inputBufferSize);
if (outputBufferSize!=null)
session.setOutputBufferSize(outputBufferSize);
coreSession.setOutputBufferSize(outputBufferSize);
if (maxBinaryMessageSize!=null)
session.setMaxBinaryMessageSize(maxBinaryMessageSize);
coreSession.setMaxBinaryMessageSize(maxBinaryMessageSize);
if (maxTextMessageSize!=null)
session.setMaxTextMessageSize(maxTextMessageSize);
coreSession.setMaxTextMessageSize(maxTextMessageSize);
}
}

View File

@ -347,15 +347,15 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
extensionStack,
WebSocketConstants.SPEC_VERSION_STRING);
WebSocketCoreSession wsSession = newWebSocketCoreSession(frameHandler, negotiated);
wsClient.customize(wsSession);
WebSocketCoreSession coreSession = newWebSocketCoreSession(frameHandler, negotiated);
wsClient.customize(coreSession);
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), wsSession);
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), coreSession);
for (Connection.Listener listener : wsClient.getBeans(Connection.Listener.class))
wsConnection.addListener(listener);
wsSession.setWebSocketConnection(wsConnection);
coreSession.setWebSocketConnection(wsConnection);
notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(this, response));
@ -363,7 +363,7 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
try
{
endp.upgrade(wsConnection);
futureCoreSession.complete(wsSession);
futureCoreSession.complete(coreSession);
}
catch (Throwable t)
{
@ -380,9 +380,9 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
{
}
protected WebSocketConnection newWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession wsCoreSession)
protected WebSocketConnection newWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession coreSession)
{
return new WebSocketConnection(endp, executor, scheduler, byteBufferPool, wsCoreSession);
return new WebSocketConnection(endp, executor, scheduler, byteBufferPool, coreSession);
}
protected WebSocketCoreSession newWebSocketCoreSession(FrameHandler handler, Negotiated negotiated)

View File

@ -72,10 +72,10 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
if (customizer != null)
customizer.customize(session);
customizer.customize(coreSession);
}
public CompletableFuture<FrameHandler.CoreSession> connect(FrameHandler frameHandler, URI wsUri) throws IOException

View File

@ -243,7 +243,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
outgoing.sendFrame(frame, callback, batch);
}
public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketCoreSession webSocketCoreSession)
public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketCoreSession coreSession)
{
if (extensions == null)
throw new IllegalStateException();
@ -259,7 +259,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
}
for (Extension extension : extensions)
extension.setWebSocketCoreSession(webSocketCoreSession);
extension.setWebSocketCoreSession(coreSession);
}
@Override

View File

@ -58,7 +58,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
private final ByteBufferPool bufferPool;
private final Generator generator;
private final Parser parser;
private final WebSocketCoreSession session;
private final WebSocketCoreSession coreSession;
private final Flusher flusher;
private final Random random;
@ -110,7 +110,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
this.bufferPool = bufferPool;
this.session = coreSession;
this.coreSession = coreSession;
this.generator = new Generator(bufferPool);
this.parser = new Parser(bufferPool, coreSession.isAutoFragment())
@ -128,7 +128,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
this.flusher = new Flusher(scheduler, coreSession.getOutputBufferSize(), generator, endp);
this.setInputBufferSize(coreSession.getInputBufferSize());
this.random = this.session.getBehavior() == Behavior.CLIENT?new Random(endp.hashCode()):null;
this.random = this.coreSession.getBehavior() == Behavior.CLIENT?new Random(endp.hashCode()):null;
}
@Override
@ -173,8 +173,8 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
if (LOG.isDebugEnabled())
LOG.debug("onClose() of physical connection");
if (!session.isClosed())
session.onEof();
if (!coreSession.isClosed())
coreSession.onEof();
flusher.onClose(cause);
super.onClose(cause);
}
@ -187,7 +187,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
LOG.debug("onIdleExpired()");
// treat as a handler error because socket is still open
session.processHandlerError(new WebSocketTimeoutException("Connection Idle Timeout"),Callback.NOOP);
coreSession.processHandlerError(new WebSocketTimeoutException("Connection Idle Timeout"),Callback.NOOP);
return true;
}
@ -203,7 +203,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
LOG.debug("onReadTimeout()");
// treat as a handler error because socket is still open
session.processHandlerError(new WebSocketTimeoutException("Timeout on Read", timeout),Callback.NOOP);
coreSession.processHandlerError(new WebSocketTimeoutException("Timeout on Read", timeout),Callback.NOOP);
return false;
}
@ -216,7 +216,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
if (referenced != null)
referenced.retain();
session.onFrame(frame, new Callback()
coreSession.onFrame(frame, new Callback()
{
@Override
public void succeeded()
@ -228,7 +228,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
if (referenced != null)
referenced.release();
if (!session.isDemanding())
if (!coreSession.isDemanding())
demand(1);
}
@ -243,7 +243,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
referenced.release();
// notify session & endpoint
session.processHandlerError(cause,NOOP);
coreSession.processHandlerError(cause,NOOP);
}
});
}
@ -435,7 +435,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
if (filled < 0)
{
releaseNetworkBuffer();
session.onEof();
coreSession.onEof();
return;
}
@ -454,7 +454,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
LOG.warn(t.toString());
BufferUtil.clear(networkBuffer.getBuffer());
releaseNetworkBuffer();
session.processConnectionError(t,Callback.NOOP);
coreSession.processConnectionError(t,Callback.NOOP);
}
}
@ -496,7 +496,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
// Open Session
super.onOpen();
session.onOpen();
coreSession.onOpen();
}
@Override
@ -527,7 +527,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
return String.format("%s@%x[%s,p=%s,f=%s,g=%s]",
getClass().getSimpleName(),
hashCode(),
session.getBehavior(),
coreSession.getBehavior(),
parser,
flusher,
generator);
@ -586,7 +586,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
*/
void enqueueFrame(Frame frame, Callback callback, boolean batch)
{
if (session.getBehavior() == Behavior.CLIENT)
if (coreSession.getBehavior() == Behavior.CLIENT)
{
byte[] mask = new byte[4];
random.nextBytes(mask);
@ -607,7 +607,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
@Override
public void onCompleteFailure(Throwable x)
{
session.processConnectionError(x, NOOP);
coreSession.processConnectionError(x, NOOP);
super.onCompleteFailure(x);
}
}

View File

@ -101,9 +101,9 @@ public abstract class CompressExtension extends AbstractExtension
}
@Override
public void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession)
public void setWebSocketCoreSession(WebSocketCoreSession coreSession)
{
super.setWebSocketCoreSession(webSocketCoreSession);
super.setWebSocketCoreSession(coreSession);
}
public Deflater getDeflater()

View File

@ -18,14 +18,14 @@
package org.eclipse.jetty.websocket.core.server;
import java.io.IOException;
import java.util.function.Function;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.websocket.core.FrameHandler;
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
import java.io.IOException;
import java.util.function.Function;
public interface WebSocketNegotiator extends FrameHandler.Customizer
{
FrameHandler negotiate(Negotiation negotiation) throws IOException;
@ -102,10 +102,10 @@ public interface WebSocketNegotiator extends FrameHandler.Customizer
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
if (customizer != null)
customizer.customize(session);
customizer.customize(coreSession);
}
@Override

View File

@ -193,16 +193,16 @@ public final class RFC6455Handshaker implements Handshaker
WebSocketConstants.SPEC_VERSION_STRING);
// Create the Session
WebSocketCoreSession session = newWebSocketCoreSession(handler, negotiated);
WebSocketCoreSession coreSession = newWebSocketCoreSession(handler, negotiated);
if (defaultCustomizer!=null)
defaultCustomizer.customize(session);
negotiator.customize(session);
defaultCustomizer.customize(coreSession);
negotiator.customize(coreSession);
if (LOG.isDebugEnabled())
LOG.debug("session {}", session);
LOG.debug("session {}", coreSession);
// Create a connection
WebSocketConnection connection = newWebSocketConnection(httpChannel.getEndPoint(), connector.getExecutor(), connector.getScheduler(), connector.getByteBufferPool(), session);
WebSocketConnection connection = newWebSocketConnection(httpChannel.getEndPoint(), connector.getExecutor(), connector.getScheduler(), connector.getByteBufferPool(), coreSession);
if (LOG.isDebugEnabled())
LOG.debug("connection {}", connection);
if (connection == null)
@ -211,7 +211,7 @@ public final class RFC6455Handshaker implements Handshaker
for (Connection.Listener listener : connector.getBeans(Connection.Listener.class))
connection.addListener(listener);
session.setWebSocketConnection(connection);
coreSession.setWebSocketConnection(connection);
// send upgrade response
Response baseResponse = baseRequest.getResponse();
@ -231,7 +231,7 @@ public final class RFC6455Handshaker implements Handshaker
// upgrade
if (LOG.isDebugEnabled())
LOG.debug("upgrade connection={} session={}", connection, session);
LOG.debug("upgrade connection={} session={}", connection, coreSession);
baseRequest.setAttribute(HttpConnection.UPGRADE_CONNECTION_ATTRIBUTE, connection);
return true;
@ -242,9 +242,9 @@ public final class RFC6455Handshaker implements Handshaker
return new WebSocketCoreSession(handler, Behavior.SERVER, negotiated);
}
protected WebSocketConnection newWebSocketConnection(EndPoint endPoint, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession wsCoreSession)
protected WebSocketConnection newWebSocketConnection(EndPoint endPoint, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession coreSession)
{
return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, wsCoreSession);
return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, coreSession);
}
private boolean getSendServerVersion(Connector connector)

View File

@ -41,17 +41,17 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
private byte partial = OpCode.UNDEFINED;
private Utf8StringBuilder utf8;
private ByteBuffer byteBuffer;
private FrameHandler.CoreSession session;
private FrameHandler.CoreSession coreSession;
public FrameHandler.CoreSession getCoreSession()
{
return session;
return coreSession;
}
@Override
public void onOpen(CoreSession coreSession)
{
this.session = coreSession;
this.coreSession = coreSession;
onOpen();
}
@ -121,7 +121,7 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
try
{
session.sendFrame(new Frame(PONG).setPayload(pongBuf), callback, false);
coreSession.sendFrame(new Frame(PONG).setPayload(pongBuf), callback, false);
}
catch (Throwable t)
{
@ -338,7 +338,7 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
}
if (respond > 0)
session.close(respond, reason, callback);
coreSession.close(respond, reason, callback);
else
callback.succeeded();
}

View File

@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
public class GeneratorFrameFlagsTest
{
private static ByteBufferPool bufferPool = new MappedByteBufferPool();
private WebSocketCoreSession session;
private WebSocketCoreSession coreSession;
public static Stream<Arguments> data()
{
@ -65,7 +65,7 @@ public class GeneratorFrameFlagsTest
{
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
this.session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.CLIENT, Negotiated.from(exStack));
this.coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.CLIENT, Negotiated.from(exStack));
}
@ParameterizedTest
@ -76,6 +76,6 @@ public class GeneratorFrameFlagsTest
ByteBuffer buffer = ByteBuffer.allocate(100);
new Generator(bufferPool).generateWholeFrame(invalidFrame, buffer);
assertThrows(ProtocolException.class, () -> session.assertValidOutgoing(invalidFrame));
assertThrows(ProtocolException.class, () -> coreSession.assertValidOutgoing(invalidFrame));
}
}

View File

@ -50,7 +50,7 @@ public class GeneratorTest
private static final Logger LOG = Log.getLogger(Helper.class);
private static Generator generator = new Generator(new MappedByteBufferPool());
private static WebSocketCoreSession session = newWebSocketCoreSession(Behavior.SERVER);
private static WebSocketCoreSession coreSession = newWebSocketCoreSession(Behavior.SERVER);
private static WebSocketCoreSession newWebSocketCoreSession(Behavior behavior)
{
@ -410,7 +410,7 @@ public class GeneratorTest
BufferUtil.flipToFlush(bb, 0);
closeFrame.setPayload(bb);
assertThrows(ProtocolException.class, () -> session.assertValidOutgoing(closeFrame));
assertThrows(ProtocolException.class, () -> coreSession.assertValidOutgoing(closeFrame));
}
/**
@ -651,7 +651,7 @@ public class GeneratorTest
Frame pingFrame = new Frame(OpCode.PING);
pingFrame.setPayload(ByteBuffer.wrap(bytes));
assertThrows(WebSocketException.class, () -> session.assertValidOutgoing(pingFrame));
assertThrows(WebSocketException.class, () -> coreSession.assertValidOutgoing(pingFrame));
}
/**
@ -665,7 +665,7 @@ public class GeneratorTest
Frame pongFrame = new Frame(OpCode.PONG);
pongFrame.setPayload(ByteBuffer.wrap(bytes));
assertThrows(WebSocketException.class, () -> session.assertValidOutgoing(pongFrame));
assertThrows(WebSocketException.class, () -> coreSession.assertValidOutgoing(pongFrame));
}
/**

View File

@ -50,7 +50,7 @@ public class MessageHandlerTest
boolean demanding;
int demand;
CoreSession session;
CoreSession coreSession;
List<String> textMessages = new ArrayList<>();
List<ByteBuffer> binaryMessages = new ArrayList<>();
List<Callback> callbacks = new ArrayList<>();
@ -63,7 +63,7 @@ public class MessageHandlerTest
demanding = false;
demand = 0;
session = new CoreSession.Empty()
coreSession = new CoreSession.Empty()
{
private ByteBufferPool byteBufferPool = new MappedByteBufferPool();
@ -110,7 +110,7 @@ public class MessageHandlerTest
}
};
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
}
@Test
@ -349,7 +349,7 @@ public class MessageHandlerTest
FutureCallback callback;
handler.setMaxTextMessageSize(4);
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
callback = new FutureCallback();
handler.onFrame(new Frame(OpCode.TEXT, true, "Testing"), callback);
@ -368,7 +368,7 @@ public class MessageHandlerTest
FutureCallback callback;
handler.setMaxTextMessageSize(4);
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
callback = new FutureCallback();
handler.onFrame(new Frame(OpCode.TEXT, false, "123"), callback);
@ -569,7 +569,7 @@ public class MessageHandlerTest
FutureCallback callback;
handler.setMaxBinaryMessageSize(4);
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
callback = new FutureCallback();
handler.onFrame(new Frame(OpCode.BINARY, true, "Testing"), callback);
@ -588,7 +588,7 @@ public class MessageHandlerTest
FutureCallback callback;
handler.setMaxBinaryMessageSize(4);
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
callback = new FutureCallback();
handler.onFrame(new Frame(OpCode.BINARY, false, "123"), callback);
@ -652,7 +652,7 @@ public class MessageHandlerTest
}
};
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
FutureCallback callback;
@ -680,7 +680,7 @@ public class MessageHandlerTest
}
};
handler.onOpen(session, NOOP);
handler.onOpen(coreSession, NOOP);
FutureCallback callback;

View File

@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.is;
public class ParserCapture
{
private final Parser parser;
private final WebSocketCoreSession session;
private final WebSocketCoreSession coreSession;
public BlockingQueue<Frame> framesQueue = new LinkedBlockingDeque<>();
public boolean closed = false;
public boolean copy;
@ -60,7 +60,7 @@ public class ParserCapture
ByteBufferPool bufferPool = new MappedByteBufferPool();
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
this.session = new WebSocketCoreSession(new AbstractTestFrameHandler(), behavior, Negotiated.from(exStack));
this.coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), behavior, Negotiated.from(exStack));
}
public void parse(ByteBuffer buffer)
@ -71,7 +71,7 @@ public class ParserCapture
if (frame == null)
break;
session.assertValidIncoming(frame);
coreSession.assertValidIncoming(frame);
if (!onFrame(frame))
break;

View File

@ -31,7 +31,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
{
private static Logger LOG = Log.getLogger(TestFrameHandler.class);
protected CoreSession session;
protected CoreSession coreSession;
public BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
protected Throwable failure;
@ -41,7 +41,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
public CoreSession getCoreSession()
{
return session;
return coreSession;
}
public BlockingQueue<Frame> getFrames()
@ -58,7 +58,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
public void onOpen(CoreSession coreSession)
{
LOG.info("onOpen {}", coreSession);
this.session = coreSession;
this.coreSession = coreSession;
open.countDown();
}

View File

@ -62,7 +62,7 @@ public class TestWebSocketNegotiator implements WebSocketNegotiator
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
}

View File

@ -413,7 +413,7 @@ public class WebSocketCloseTest extends WebSocketTester
static class DemandingTestFrameHandler implements SynchronousFrameHandler
{
private CoreSession session;
private CoreSession coreSession;
String state;
protected BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
@ -425,7 +425,7 @@ public class WebSocketCloseTest extends WebSocketTester
public CoreSession getCoreSession()
{
return session;
return coreSession;
}
public BlockingQueue<Frame> getFrames()
@ -437,8 +437,8 @@ public class WebSocketCloseTest extends WebSocketTester
public void onOpen(CoreSession coreSession)
{
LOG.debug("onOpen {}", coreSession);
session = coreSession;
state = session.toString();
this.coreSession = coreSession;
state = this.coreSession.toString();
opened.countDown();
}
@ -446,7 +446,7 @@ public class WebSocketCloseTest extends WebSocketTester
public void onFrame(Frame frame, Callback callback)
{
LOG.debug("onFrame: " + BufferUtil.toDetailString(frame.getPayload()));
state = session.toString();
state = coreSession.toString();
receivedCallback.offer(callback);
receivedFrames.offer(Frame.copy(frame));
@ -458,7 +458,7 @@ public class WebSocketCloseTest extends WebSocketTester
public void onClosed(CloseStatus closeStatus)
{
LOG.debug("onClosed {}", closeStatus);
state = session.toString();
state = coreSession.toString();
this.closeStatus = closeStatus;
closed.countDown();
}
@ -468,7 +468,7 @@ public class WebSocketCloseTest extends WebSocketTester
{
LOG.debug("onError {} ", cause);
error = cause;
state = session.toString();
state = coreSession.toString();
}
@Override
@ -484,7 +484,7 @@ public class WebSocketCloseTest extends WebSocketTester
frame.setPayload(text);
getCoreSession().sendFrame(frame, NOOP, false);
state = session.toString();
state = coreSession.toString();
}
}

View File

@ -158,12 +158,12 @@ public class WebSocketOpenTest extends WebSocketTester
return null;
});
FrameHandler.CoreSession session = sx.exchange(null);
FrameHandler.CoreSession coreSession = sx.exchange(null);
Callback onOpenCallback = cx.exchange(null);
Thread.sleep(100);
// Can send while onOpen is active
WebSocketOpenTest.TestFrameHandler.sendText(session,"Hello", NOOP);
WebSocketOpenTest.TestFrameHandler.sendText(coreSession,"Hello", NOOP);
Parser.ParsedFrame frame = receiveFrame(client.getInputStream());
assertThat(frame.getPayloadAsUTF8(),is("Hello"));
@ -172,16 +172,16 @@ public class WebSocketOpenTest extends WebSocketTester
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
// Can't demand until open
assertThrows(Throwable.class, () -> session.demand(1));
assertThrows(Throwable.class, () -> coreSession.demand(1));
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
// Succeeded moves to OPEN state and still does not read CLOSE frame
onOpenCallback.succeeded();
assertThat(session.toString(),containsString("OPEN"));
assertThat(coreSession.toString(),containsString("OPEN"));
// Demand start receiving frames
session.demand(1);
coreSession.demand(1);
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
assertTrue(serverHandler.onClosed.await(5, TimeUnit.SECONDS));
@ -198,7 +198,7 @@ public class WebSocketOpenTest extends WebSocketTester
static class TestFrameHandler implements SynchronousFrameHandler
{
private CoreSession session;
private CoreSession coreSession;
private BiFunction<CoreSession,Callback,Void> onOpen;
private CloseStatus closeStatus;
private CountDownLatch onClosed = new CountDownLatch(1);
@ -211,7 +211,7 @@ public class WebSocketOpenTest extends WebSocketTester
{
synchronized (this)
{
return session;
return coreSession;
}
}
@ -226,7 +226,7 @@ public class WebSocketOpenTest extends WebSocketTester
LOG.info("onOpen {}", coreSession);
synchronized (this)
{
session = coreSession;
this.coreSession = coreSession;
}
onOpen.apply(coreSession, callback);
}
@ -271,25 +271,25 @@ public class WebSocketOpenTest extends WebSocketTester
public void sendText(String text)
{
sendText(session, text);
sendText(coreSession, text);
}
public void sendText(String text, Callback callback)
{
sendText(session, text, callback);
sendText(coreSession, text, callback);
}
static void sendText(FrameHandler.CoreSession session, String text)
static void sendText(FrameHandler.CoreSession coreSession, String text)
{
sendText(session, text, NOOP);
sendText(coreSession, text, NOOP);
}
static void sendText(FrameHandler.CoreSession session, String text, Callback callback)
static void sendText(FrameHandler.CoreSession coreSession, String text, Callback callback)
{
Frame frame = new Frame(OpCode.TEXT);
frame.setFin(true);
frame.setPayload(text);
session.sendFrame(frame, callback, false);
coreSession.sendFrame(frame, callback, false);
}
}
}

View File

@ -82,12 +82,12 @@ class AutobahnWebSocketNegotiator implements WebSocketNegotiator
}
@Override
public void customize(FrameHandler.CoreSession session)
public void customize(FrameHandler.CoreSession coreSession)
{
session.setIdleTimeout(Duration.ofMillis(10000));
session.setMaxTextMessageSize(Integer.MAX_VALUE);
session.setMaxBinaryMessageSize(Integer.MAX_VALUE);
session.setMaxFrameSize(65536*2);
coreSession.setIdleTimeout(Duration.ofMillis(10000));
coreSession.setMaxTextMessageSize(Integer.MAX_VALUE);
coreSession.setMaxBinaryMessageSize(Integer.MAX_VALUE);
coreSession.setMaxFrameSize(65536*2);
}
@Override

View File

@ -422,8 +422,8 @@ public class DeflateFrameExtensionTest extends AbstractExtensionTest
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
WebSocketCoreSession session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
session.setMaxFrameSize(maxMessageSize);
return session;
WebSocketCoreSession coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
coreSession.setMaxFrameSize(maxMessageSize);
return coreSession;
}
}

View File

@ -155,7 +155,7 @@ public class ExtensionTool
ByteBufferPool bufferPool = new MappedByteBufferPool();
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
WebSocketCoreSession session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
return session;
WebSocketCoreSession coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
return coreSession;
}
}