Issue #2175 cleanups after review

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-01-22 09:11:05 +11:00
parent 8aca98976d
commit f9b9cc1313
9 changed files with 52 additions and 30 deletions

View File

@ -32,7 +32,14 @@ import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.pathmap.PathSpec; import org.eclipse.jetty.http.pathmap.PathSpec;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.server.*; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;

View File

@ -38,7 +38,9 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
/** /**
* Tests a {@link javax.websocket.Decoder.TextStream} automatic decoding to a Socket onMessage parameter * Tests a {@link javax.websocket.Decoder.TextStream} automatic decoding to a Socket onMessage parameter

View File

@ -25,7 +25,12 @@ import java.net.URI;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.websocket.*; import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpointConfig; import javax.websocket.server.ServerEndpointConfig;

View File

@ -31,7 +31,13 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.websocket.*; import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import javax.websocket.server.ServerEndpoint; import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;

View File

@ -19,18 +19,15 @@
package org.eclipse.jetty.websocket.core.internal; package org.eclipse.jetty.websocket.core.internal;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Queue;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
@ -201,7 +198,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
outgoing.sendFrame(frame, callback, batch); outgoing.sendFrame(frame, callback, batch);
} }
public void connect(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketChannel webSocketChannel) public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketChannel webSocketChannel)
{ {
if (extensions == null) if (extensions == null)
throw new IllegalStateException(); throw new IllegalStateException();

View File

@ -79,7 +79,7 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio
this.behavior = behavior; this.behavior = behavior;
this.negotiated = negotiated; this.negotiated = negotiated;
this.demanding = handler.isDemanding(); this.demanding = handler.isDemanding();
negotiated.getExtensions().connect(new IncomingAdaptor(), new OutgoingAdaptor(), this); negotiated.getExtensions().initialize(new IncomingAdaptor(), new OutgoingAdaptor(), this);
} }
/** /**
@ -153,7 +153,7 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio
if (frame.getOpCode() == OpCode.CLOSE) if (frame.getOpCode() == OpCode.CLOSE)
{ {
if (!(frame instanceof ParsedFrame)) // already check in parser if (!(frame instanceof ParsedFrame)) // already check in parser
CloseStatus.getCloseStatus(frame); CloseStatus.getCloseStatus(frame); // return ignored as get used to validate there is a closeStatus
} }
} }
else else
@ -237,7 +237,7 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio
@Override @Override
public boolean isOpen() public boolean isOpen()
{ {
return channelState.isOutOpen(); return channelState.isOutputOpen();
} }
public void setWebSocketConnection(WebSocketConnection connection) public void setWebSocketConnection(WebSocketConnection connection)
@ -640,7 +640,7 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio
@Override @Override
public void completed() public void completed()
{ {
if (channelState.isOutOpen()) if (channelState.isOutputOpen())
{ {
CloseStatus closeStatus = CloseStatus.getCloseStatus(frame); CloseStatus closeStatus = CloseStatus.getCloseStatus(frame);

View File

@ -33,8 +33,8 @@ public class WebSocketChannelState
CONNECTING, CONNECTING,
CONNECTED, CONNECTED,
OPEN, OPEN,
ICLOSED, ISHUT,
OCLOSED, OSHUT,
CLOSED CLOSED
} }
@ -85,16 +85,16 @@ public class WebSocketChannelState
return getState()==State.CLOSED; return getState()==State.CLOSED;
} }
public boolean isInOpen() public boolean isInputOpen()
{ {
State state = getState(); State state = getState();
return (state==State.OPEN || state==State.OCLOSED); return (state==State.OPEN || state==State.OSHUT);
} }
public boolean isOutOpen() public boolean isOutputOpen()
{ {
State state = getState(); State state = getState();
return (state==State.OPEN || state==State.ICLOSED); return (state==State.OPEN || state==State.ISHUT);
} }
public CloseStatus getCloseStatus() public CloseStatus getCloseStatus()
@ -125,7 +125,7 @@ public class WebSocketChannelState
synchronized (this) synchronized (this)
{ {
if (!isOutOpen()) if (!isOutputOpen())
throw new IllegalStateException(_channelState.toString()); throw new IllegalStateException(_channelState.toString());
if (opcode == OpCode.CLOSE) if (opcode == OpCode.CLOSE)
@ -135,9 +135,9 @@ public class WebSocketChannelState
switch (_channelState) switch (_channelState)
{ {
case OPEN: case OPEN:
_channelState = State.OCLOSED; _channelState = State.OSHUT;
return false; return false;
case ICLOSED: case ISHUT:
_channelState = State.CLOSED; _channelState = State.CLOSED;
return true; return true;
default: default:
@ -160,7 +160,7 @@ public class WebSocketChannelState
synchronized (this) synchronized (this)
{ {
if (!isInOpen()) if (!isInputOpen())
throw new IllegalStateException(_channelState.toString()); throw new IllegalStateException(_channelState.toString());
if (opcode == OpCode.CLOSE) if (opcode == OpCode.CLOSE)
@ -170,9 +170,9 @@ public class WebSocketChannelState
switch (_channelState) switch (_channelState)
{ {
case OPEN: case OPEN:
_channelState = State.ICLOSED; _channelState = State.ISHUT;
return false; return false;
case OCLOSED: case OSHUT:
_channelState = State.CLOSED; _channelState = State.CLOSED;
return true; return true;
default: default:

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.core.extensions; package org.eclipse.jetty.websocket.core.extensions;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.DecoratedObjectFactory;
@ -35,9 +38,6 @@ import org.eclipse.jetty.websocket.core.internal.IdentityExtension;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -80,7 +80,7 @@ public class ExtensionStackTest
// Setup Listeners // Setup Listeners
IncomingFrames session = new IncomingFramesCapture(); IncomingFrames session = new IncomingFramesCapture();
OutgoingFrames connection = new OutgoingFramesCapture(); OutgoingFrames connection = new OutgoingFramesCapture();
stack.connect(session, connection, null); stack.initialize(session, connection, null);
// Dump // Dump
LOG.debug("{}", stack.dump()); LOG.debug("{}", stack.dump());
@ -104,7 +104,7 @@ public class ExtensionStackTest
// Setup Listeners // Setup Listeners
IncomingFrames session = new IncomingFramesCapture(); IncomingFrames session = new IncomingFramesCapture();
OutgoingFrames connection = new OutgoingFramesCapture(); OutgoingFrames connection = new OutgoingFramesCapture();
stack.connect(session, connection, null); stack.initialize(session, connection, null);
// Dump // Dump
LOG.debug("{}", stack.dump()); LOG.debug("{}", stack.dump());

View File

@ -27,7 +27,12 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.pathmap.*; import org.eclipse.jetty.http.pathmap.MappedResource;
import org.eclipse.jetty.http.pathmap.PathMappings;
import org.eclipse.jetty.http.pathmap.PathSpec;
import org.eclipse.jetty.http.pathmap.RegexPathSpec;
import org.eclipse.jetty.http.pathmap.ServletPathSpec;
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.io.RuntimeIOException;