Merge pull request #5235 from eclipse/jetty-10.0.x-Jetty-WS-API-Cleanup

Jetty WebSocket API minor cleanups before Jetty-10 full release
This commit is contained in:
Lachlan 2020-09-09 15:22:24 +10:00 committed by GitHub
commit 7a6404d9fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 66 additions and 62 deletions

View File

@ -16,12 +16,14 @@
// ========================================================================
//
import org.eclipse.jetty.websocket.api.ExtensionConfig;
module org.eclipse.jetty.websocket.jetty.api
{
exports org.eclipse.jetty.websocket.api;
exports org.eclipse.jetty.websocket.api.annotations;
exports org.eclipse.jetty.websocket.api.extensions;
exports org.eclipse.jetty.websocket.api.exceptions;
exports org.eclipse.jetty.websocket.api.util;
uses org.eclipse.jetty.websocket.api.extensions.ExtensionConfig.Parser;
uses ExtensionConfig.Parser;
}

View File

@ -23,8 +23,8 @@ public class CloseStatus
private static final int MAX_CONTROL_PAYLOAD = 125;
public static final int MAX_REASON_PHRASE = MAX_CONTROL_PAYLOAD - 2;
private int code;
private String phrase;
private final int code;
private final String phrase;
/**
* Creates a reason for closing a web socket connection with the given code and reason phrase.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api.extensions;
package org.eclipse.jetty.websocket.api;
import java.util.Map;
import java.util.ServiceLoader;

View File

@ -46,7 +46,7 @@ public interface Frame
throw new IllegalArgumentException("OpCode " + op + " is not a valid Frame.Type");
}
private byte opcode;
private final byte opcode;
Type(byte code)
{

View File

@ -24,8 +24,6 @@ import java.security.Principal;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
/**
* The HTTP Upgrade to WebSocket Request
*/

View File

@ -22,8 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
/**
* The HTTP Upgrade to WebSocket Response
*/

View File

@ -39,14 +39,12 @@ public class WebSocketAdapter implements WebSocketListener
public boolean isConnected()
{
Session sess = this.session;
return (sess != null) && (sess.isOpen());
return session.isOpen();
}
public boolean isNotConnected()
{
Session sess = this.session;
return (sess == null) || (!sess.isOpen());
return !isConnected();
}
@Override

View File

@ -16,7 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import org.eclipse.jetty.websocket.api.StatusCode;
/**
* Exception to terminate the connection because it has received data within a frame payload that was not consistent with the requirements of that frame

View File

@ -16,12 +16,12 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
@SuppressWarnings("serial")
public class CloseException extends WebSocketException
{
private int statusCode;
private final int statusCode;
public CloseException(int closeCode, String message)
{

View File

@ -16,8 +16,10 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
/**

View File

@ -16,7 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import org.eclipse.jetty.websocket.api.StatusCode;
/**
* Exception when a message is too large for the internal buffers occurs and should trigger a connection close.

View File

@ -16,7 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import org.eclipse.jetty.websocket.api.StatusCode;
/**
* Exception when a violation of policy occurs and should trigger a connection close.

View File

@ -16,7 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import org.eclipse.jetty.websocket.api.StatusCode;
/**
* Per spec, a protocol error should result in a Close frame of status code 1002 (PROTOCOL_ERROR)

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
import java.net.URI;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
/**
* A recoverable exception within the websocket framework.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;
/**
* Exception thrown to indicate a connection I/O timeout.

View File

@ -17,7 +17,7 @@
//
/**
* Jetty WebSocket API : WebSocket Extension API
* Jetty WebSocket API : Exception Types
*/
package org.eclipse.jetty.websocket.api.extensions;
package org.eclipse.jetty.websocket.api.exceptions;

View File

@ -22,8 +22,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
// @checkstyle-disable-check : AbbreviationAsWordInNameCheck
/**
* Utility methods for converting a {@link URI} between a HTTP(S) and WS(S) URI.
*/

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.util;
public final class WebSocketConstants
{

View File

@ -31,9 +31,9 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
/**
* Client based UpgradeRequest API

View File

@ -32,8 +32,8 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.UrlEncoded;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest;
import static java.nio.charset.StandardCharsets.UTF_8;

View File

@ -26,8 +26,8 @@ import java.util.stream.Collectors;
import org.eclipse.jetty.client.HttpResponse;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
/**
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse}

View File

@ -16,7 +16,7 @@
// ========================================================================
//
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.ExtensionConfigParser;
module org.eclipse.jetty.websocket.jetty.common

View File

@ -20,7 +20,7 @@ package org.eclipse.jetty.websocket.common;
import org.eclipse.jetty.websocket.core.ExtensionConfig;
public class ExtensionConfigParser implements org.eclipse.jetty.websocket.api.extensions.ExtensionConfig.Parser
public class ExtensionConfigParser implements org.eclipse.jetty.websocket.api.ExtensionConfig.Parser
{
/**
* Parse a single parameterized name.

View File

@ -26,7 +26,7 @@ import org.eclipse.jetty.websocket.core.ExtensionConfig;
/**
* Represents an Extension Configuration, as seen during the connection Handshake process.
*/
public class JettyExtensionConfig implements org.eclipse.jetty.websocket.api.extensions.ExtensionConfig
public class JettyExtensionConfig implements org.eclipse.jetty.websocket.api.ExtensionConfig
{
private final ExtensionConfig config;

View File

@ -507,27 +507,27 @@ public class JettyWebSocketFrameHandler implements FrameHandler
public static Throwable convertCause(Throwable cause)
{
if (cause instanceof MessageTooLargeException)
return new org.eclipse.jetty.websocket.api.MessageTooLargeException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException(cause.getMessage(), cause);
if (cause instanceof ProtocolException)
return new org.eclipse.jetty.websocket.api.ProtocolException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.ProtocolException(cause.getMessage(), cause);
if (cause instanceof BadPayloadException)
return new org.eclipse.jetty.websocket.api.BadPayloadException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.BadPayloadException(cause.getMessage(), cause);
if (cause instanceof CloseException)
return new org.eclipse.jetty.websocket.api.CloseException(((CloseException)cause).getStatusCode(), cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.CloseException(((CloseException)cause).getStatusCode(), cause.getMessage(), cause);
if (cause instanceof WebSocketTimeoutException)
return new org.eclipse.jetty.websocket.api.WebSocketTimeoutException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException(cause.getMessage(), cause);
if (cause instanceof InvalidSignatureException)
return new org.eclipse.jetty.websocket.api.InvalidWebSocketException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException(cause.getMessage(), cause);
if (cause instanceof UpgradeException)
{
UpgradeException ue = (UpgradeException)cause;
return new org.eclipse.jetty.websocket.api.UpgradeException(ue.getRequestURI(), ue.getResponseStatusCode(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.UpgradeException(ue.getRequestURI(), ue.getResponseStatusCode(), cause);
}
return cause;

View File

@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.common;
import java.lang.invoke.MethodHandle;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException;
import org.eclipse.jetty.websocket.core.Configuration;
import org.eclipse.jetty.websocket.util.messages.MessageSink;

View File

@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException;
import org.eclipse.jetty.websocket.util.DuplicateAnnotationException;
import org.eclipse.jetty.websocket.util.InvalidSignatureException;
import org.eclipse.jetty.websocket.util.messages.ByteArrayMessageSink;

View File

@ -21,9 +21,9 @@ package org.eclipse.jetty.websocket.server;
import java.io.IOException;
import java.util.List;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
public interface JettyServerUpgradeResponse extends UpgradeResponse
{

View File

@ -150,7 +150,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
}
catch (Exception e)
{
throw new org.eclipse.jetty.websocket.api.WebSocketException("Unable to create instance of " + endpointClass.getName(), e);
throw new org.eclipse.jetty.websocket.api.exceptions.WebSocketException("Unable to create instance of " + endpointClass.getName(), e);
}
});
}

View File

@ -31,7 +31,7 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;

View File

@ -24,7 +24,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;

View File

@ -37,7 +37,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
import org.eclipse.jetty.websocket.server.JettyWebSocketCreator;

View File

@ -30,8 +30,8 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.JettyUpgradeListener;
import org.eclipse.jetty.websocket.client.WebSocketClient;

View File

@ -59,7 +59,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.api.exceptions.UpgradeException;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;

View File

@ -37,12 +37,12 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.BlockingArrayQueue;
import org.eclipse.jetty.websocket.api.Frame;
import org.eclipse.jetty.websocket.api.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketFrameListener;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.core.CloseStatus;

View File

@ -29,11 +29,11 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.core.internal.WebSocketConnection;

View File

@ -40,7 +40,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.api.exceptions.UpgradeException;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.api.exceptions.UpgradeException;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;

View File

@ -34,9 +34,9 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.WebSocketSessionListener;
import org.eclipse.jetty.websocket.api.exceptions.UpgradeException;
import org.eclipse.jetty.websocket.api.exceptions.WebSocketException;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.JettyUpgradeListener;

View File

@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.tests.extensions;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;

View File

@ -33,11 +33,11 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.core.internal.WebSocketConnection;