This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 3a378cae7c574f42cf1f27cabb9edc440a6d8770 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Apr 14 11:36:57 2023 +0100 Code clean-up - no functional change --- java/javax/websocket/ClientEndpoint.java | 6 +- java/javax/websocket/ClientEndpointConfig.java | 34 ++-- java/javax/websocket/CloseReason.java | 6 +- java/javax/websocket/ContainerProvider.java | 17 +- java/javax/websocket/DecodeException.java | 3 +- .../websocket/DefaultClientEndpointConfig.java | 8 +- java/javax/websocket/Encoder.java | 6 +- java/javax/websocket/Endpoint.java | 9 +- java/javax/websocket/EndpointConfig.java | 2 +- java/javax/websocket/Extension.java | 2 + java/javax/websocket/HandshakeResponse.java | 2 +- java/javax/websocket/MessageHandler.java | 7 +- java/javax/websocket/PongMessage.java | 6 +- java/javax/websocket/RemoteEndpoint.java | 186 ++++++++++----------- java/javax/websocket/SendResult.java | 2 +- java/javax/websocket/Session.java | 95 +++++------ java/javax/websocket/WebSocketContainer.java | 70 ++++---- .../server/DefaultServerEndpointConfig.java | 11 +- java/javax/websocket/server/HandshakeRequest.java | 12 +- java/javax/websocket/server/PathParam.java | 5 +- .../websocket/server/ServerApplicationConfig.java | 27 ++- java/javax/websocket/server/ServerEndpoint.java | 7 +- .../websocket/server/ServerEndpointConfig.java | 72 +++----- 23 files changed, 262 insertions(+), 333 deletions(-) diff --git a/java/javax/websocket/ClientEndpoint.java b/java/javax/websocket/ClientEndpoint.java index 7de59fc0cb..f5cf516fa4 100644 --- a/java/javax/websocket/ClientEndpoint.java +++ b/java/javax/websocket/ClientEndpoint.java @@ -27,8 +27,10 @@ import javax.websocket.ClientEndpointConfig.Configurator; @Target(ElementType.TYPE) public @interface ClientEndpoint { String[] subprotocols() default {}; + Class<? extends Decoder>[] decoders() default {}; + Class<? extends Encoder>[] encoders() default {}; - Class<? extends Configurator> configurator() - default Configurator.class; + + Class<? extends Configurator> configurator() default Configurator.class; } diff --git a/java/javax/websocket/ClientEndpointConfig.java b/java/javax/websocket/ClientEndpointConfig.java index 61a4b108a6..86dbeb45ed 100644 --- a/java/javax/websocket/ClientEndpointConfig.java +++ b/java/javax/websocket/ClientEndpointConfig.java @@ -30,8 +30,8 @@ public interface ClientEndpointConfig extends EndpointConfig { final class Builder { - private static final Configurator DEFAULT_CONFIGURATOR = - new Configurator() {}; + private static final Configurator DEFAULT_CONFIGURATOR = new Configurator() { + }; public static Builder create() { @@ -46,15 +46,12 @@ public interface ClientEndpointConfig extends EndpointConfig { private Configurator configurator = DEFAULT_CONFIGURATOR; private List<String> preferredSubprotocols = Collections.emptyList(); private List<Extension> extensions = Collections.emptyList(); - private List<Class<? extends Encoder>> encoders = - Collections.emptyList(); - private List<Class<? extends Decoder>> decoders = - Collections.emptyList(); + private List<Class<? extends Encoder>> encoders = Collections.emptyList(); + private List<Class<? extends Decoder>> decoders = Collections.emptyList(); public ClientEndpointConfig build() { - return new DefaultClientEndpointConfig(preferredSubprotocols, - extensions, encoders, decoders, configurator); + return new DefaultClientEndpointConfig(preferredSubprotocols, extensions, encoders, decoders, configurator); } @@ -68,21 +65,17 @@ public interface ClientEndpointConfig extends EndpointConfig { } - public Builder preferredSubprotocols( - List<String> preferredSubprotocols) { - if (preferredSubprotocols == null || - preferredSubprotocols.size() == 0) { + public Builder preferredSubprotocols(List<String> preferredSubprotocols) { + if (preferredSubprotocols == null || preferredSubprotocols.size() == 0) { this.preferredSubprotocols = Collections.emptyList(); } else { - this.preferredSubprotocols = - Collections.unmodifiableList(preferredSubprotocols); + this.preferredSubprotocols = Collections.unmodifiableList(preferredSubprotocols); } return this; } - public Builder extensions( - List<Extension> extensions) { + public Builder extensions(List<Extension> extensions) { if (extensions == null || extensions.size() == 0) { this.extensions = Collections.emptyList(); } else { @@ -116,18 +109,17 @@ public interface ClientEndpointConfig extends EndpointConfig { class Configurator { /** - * Provides the client with a mechanism to inspect and/or modify the headers - * that are sent to the server to start the WebSocket handshake. + * Provides the client with a mechanism to inspect and/or modify the headers that are sent to the server to + * start the WebSocket handshake. * - * @param headers The HTTP headers + * @param headers The HTTP headers */ public void beforeRequest(Map<String, List<String>> headers) { // NO-OP } /** - * Provides the client with a mechanism to inspect the handshake response - * that is returned from the server. + * Provides the client with a mechanism to inspect the handshake response that is returned from the server. * * @param handshakeResponse The response */ diff --git a/java/javax/websocket/CloseReason.java b/java/javax/websocket/CloseReason.java index ef88d135d8..ecbf319c2d 100644 --- a/java/javax/websocket/CloseReason.java +++ b/java/javax/websocket/CloseReason.java @@ -36,8 +36,7 @@ public class CloseReason { @Override public String toString() { - return "CloseReason: code [" + closeCode.getCode() + - "], reason [" + reasonPhrase + "]"; + return "CloseReason: code [" + closeCode.getCode() + "], reason [" + reasonPhrase + "]"; } public interface CloseCode { @@ -109,8 +108,7 @@ public class CloseReason { case 1015: return CloseCodes.TLS_HANDSHAKE_FAILURE; default: - throw new IllegalArgumentException( - "Invalid close code: [" + code + "]"); + throw new IllegalArgumentException("Invalid close code: [" + code + "]"); } } diff --git a/java/javax/websocket/ContainerProvider.java b/java/javax/websocket/ContainerProvider.java index f95c9ade16..77623567ed 100644 --- a/java/javax/websocket/ContainerProvider.java +++ b/java/javax/websocket/ContainerProvider.java @@ -20,13 +20,11 @@ import java.util.Iterator; import java.util.ServiceLoader; /** - * Use the {@link ServiceLoader} mechanism to provide instances of the WebSocket - * client container. + * Use the {@link ServiceLoader} mechanism to provide instances of the WebSocket client container. */ public abstract class ContainerProvider { - private static final String DEFAULT_PROVIDER_CLASS_NAME = - "org.apache.tomcat.websocket.WsWebSocketContainer"; + private static final String DEFAULT_PROVIDER_CLASS_NAME = "org.apache.tomcat.websocket.WsWebSocketContainer"; /** * Create a new container used to create outgoing WebSocket connections. @@ -36,8 +34,7 @@ public abstract class ContainerProvider { public static WebSocketContainer getWebSocketContainer() { WebSocketContainer result = null; - ServiceLoader<ContainerProvider> serviceLoader = - ServiceLoader.load(ContainerProvider.class); + ServiceLoader<ContainerProvider> serviceLoader = ServiceLoader.load(ContainerProvider.class); Iterator<ContainerProvider> iter = serviceLoader.iterator(); while (result == null && iter.hasNext()) { result = iter.next().getContainer(); @@ -47,12 +44,10 @@ public abstract class ContainerProvider { if (result == null) { try { @SuppressWarnings("unchecked") - Class<WebSocketContainer> clazz = - (Class<WebSocketContainer>) Class.forName( - DEFAULT_PROVIDER_CLASS_NAME); + Class<WebSocketContainer> clazz = (Class<WebSocketContainer>) Class + .forName(DEFAULT_PROVIDER_CLASS_NAME); result = clazz.getConstructor().newInstance(); - } catch (ReflectiveOperationException | IllegalArgumentException | - SecurityException e) { + } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { // No options left. Just return null. } } diff --git a/java/javax/websocket/DecodeException.java b/java/javax/websocket/DecodeException.java index 771cfa5803..aae81204e8 100644 --- a/java/javax/websocket/DecodeException.java +++ b/java/javax/websocket/DecodeException.java @@ -30,8 +30,7 @@ public class DecodeException extends Exception { this.bb = bb; } - public DecodeException(String encodedString, String message, - Throwable cause) { + public DecodeException(String encodedString, String message, Throwable cause) { super(message, cause); this.encodedString = encodedString; } diff --git a/java/javax/websocket/DefaultClientEndpointConfig.java b/java/javax/websocket/DefaultClientEndpointConfig.java index 27905a9111..306b075472 100644 --- a/java/javax/websocket/DefaultClientEndpointConfig.java +++ b/java/javax/websocket/DefaultClientEndpointConfig.java @@ -26,14 +26,12 @@ final class DefaultClientEndpointConfig implements ClientEndpointConfig { private final List<Extension> extensions; private final List<Class<? extends Encoder>> encoders; private final List<Class<? extends Decoder>> decoders; - private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String, Object> userProperties = new ConcurrentHashMap<>(); private final Configurator configurator; - DefaultClientEndpointConfig(List<String> preferredSubprotocols, - List<Extension> extensions, - List<Class<? extends Encoder>> encoders, - List<Class<? extends Decoder>> decoders, + DefaultClientEndpointConfig(List<String> preferredSubprotocols, List<Extension> extensions, + List<Class<? extends Encoder>> encoders, List<Class<? extends Decoder>> decoders, Configurator configurator) { this.preferredSubprotocols = preferredSubprotocols; this.extensions = extensions; diff --git a/java/javax/websocket/Encoder.java b/java/javax/websocket/Encoder.java index 9a03589966..22a225b628 100644 --- a/java/javax/websocket/Encoder.java +++ b/java/javax/websocket/Encoder.java @@ -42,8 +42,7 @@ public interface Encoder { interface TextStream<T> extends Encoder { - void encode(T object, Writer writer) - throws EncodeException, IOException; + void encode(T object, Writer writer) throws EncodeException, IOException; } interface Binary<T> extends Encoder { @@ -53,7 +52,6 @@ public interface Encoder { interface BinaryStream<T> extends Encoder { - void encode(T object, OutputStream os) - throws EncodeException, IOException; + void encode(T object, OutputStream os) throws EncodeException, IOException; } } diff --git a/java/javax/websocket/Endpoint.java b/java/javax/websocket/Endpoint.java index 9dfdbcce2b..a7d7fb6716 100644 --- a/java/javax/websocket/Endpoint.java +++ b/java/javax/websocket/Endpoint.java @@ -21,17 +21,16 @@ public abstract class Endpoint { /** * Event that is triggered when a new session starts. * - * @param session The new session. - * @param config The configuration with which the Endpoint was - * configured. + * @param session The new session. + * @param config The configuration with which the Endpoint was configured. */ public abstract void onOpen(Session session, EndpointConfig config); /** * Event that is triggered when a session has closed. * - * @param session The session - * @param closeReason Why the session was closed + * @param session The session + * @param closeReason Why the session was closed */ public void onClose(Session session, CloseReason closeReason) { // NO-OP by default diff --git a/java/javax/websocket/EndpointConfig.java b/java/javax/websocket/EndpointConfig.java index 0b6c96818d..7cac76e752 100644 --- a/java/javax/websocket/EndpointConfig.java +++ b/java/javax/websocket/EndpointConfig.java @@ -25,5 +25,5 @@ public interface EndpointConfig { List<Class<? extends Decoder>> getDecoders(); - Map<String,Object> getUserProperties(); + Map<String, Object> getUserProperties(); } diff --git a/java/javax/websocket/Extension.java b/java/javax/websocket/Extension.java index b95b27b8bd..0f2c3fa764 100644 --- a/java/javax/websocket/Extension.java +++ b/java/javax/websocket/Extension.java @@ -20,10 +20,12 @@ import java.util.List; public interface Extension { String getName(); + List<Parameter> getParameters(); interface Parameter { String getName(); + String getValue(); } } diff --git a/java/javax/websocket/HandshakeResponse.java b/java/javax/websocket/HandshakeResponse.java index a932192218..a25c1a2de4 100644 --- a/java/javax/websocket/HandshakeResponse.java +++ b/java/javax/websocket/HandshakeResponse.java @@ -26,5 +26,5 @@ public interface HandshakeResponse { */ String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept"; - Map<String,List<String>> getHeaders(); + Map<String, List<String>> getHeaders(); } diff --git a/java/javax/websocket/MessageHandler.java b/java/javax/websocket/MessageHandler.java index 2c30d99779..9918d37370 100644 --- a/java/javax/websocket/MessageHandler.java +++ b/java/javax/websocket/MessageHandler.java @@ -23,9 +23,8 @@ public interface MessageHandler { /** * Called when part of a message is available to be processed. * - * @param messagePart The message part - * @param last <code>true</code> if this is the last part of - * this message, else <code>false</code> + * @param messagePart The message part + * @param last <code>true</code> if this is the last part of this message, else <code>false</code> */ void onMessage(T messagePart, boolean last); } @@ -35,7 +34,7 @@ public interface MessageHandler { /** * Called when a whole message is available to be processed. * - * @param message The message + * @param message The message */ void onMessage(T message); } diff --git a/java/javax/websocket/PongMessage.java b/java/javax/websocket/PongMessage.java index 7e9e3b6a33..4ca68d3464 100644 --- a/java/javax/websocket/PongMessage.java +++ b/java/javax/websocket/PongMessage.java @@ -19,14 +19,14 @@ package javax.websocket; import java.nio.ByteBuffer; /** - * Represents a WebSocket Pong message and used by message handlers to enable - * applications to process the response to any Pings they send. + * Represents a WebSocket Pong message and used by message handlers to enable applications to process the response to + * any Pings they send. */ public interface PongMessage { /** * Get the payload of the Pong message. * - * @return The payload of the Pong message. + * @return The payload of the Pong message. */ ByteBuffer getApplicationData(); } diff --git a/java/javax/websocket/RemoteEndpoint.java b/java/javax/websocket/RemoteEndpoint.java index 19c7a10028..74ac9927c9 100644 --- a/java/javax/websocket/RemoteEndpoint.java +++ b/java/javax/websocket/RemoteEndpoint.java @@ -28,78 +28,82 @@ public interface RemoteEndpoint { interface Async extends RemoteEndpoint { /** - * Obtain the timeout (in milliseconds) for sending a message - * asynchronously. The default value is determined by + * Obtain the timeout (in milliseconds) for sending a message asynchronously. The default value is determined by * {@link WebSocketContainer#getDefaultAsyncSendTimeout()}. - * @return The current send timeout in milliseconds. A non-positive - * value means an infinite timeout. + * + * @return The current send timeout in milliseconds. A non-positive value means an infinite timeout. */ long getSendTimeout(); /** - * Set the timeout (in milliseconds) for sending a message - * asynchronously. The default value is determined by + * Set the timeout (in milliseconds) for sending a message asynchronously. The default value is determined by * {@link WebSocketContainer#getDefaultAsyncSendTimeout()}. - * @param timeout The new timeout for sending messages asynchronously - * in milliseconds. A non-positive value means an - * infinite timeout. + * + * @param timeout The new timeout for sending messages asynchronously in milliseconds. A non-positive value + * means an infinite timeout. */ void setSendTimeout(long timeout); /** - * Send the message asynchronously, using the SendHandler to signal to the - * client when the message has been sent. - * @param text The text message to send - * @param completion Used to signal to the client when the message has - * been sent + * Send the message asynchronously, using the SendHandler to signal to the client when the message has been + * sent. + * + * @param text The text message to send + * @param completion Used to signal to the client when the message has been sent */ void sendText(String text, SendHandler completion); /** - * Send the message asynchronously, using the Future to signal to the - * client when the message has been sent. - * @param text The text message to send + * Send the message asynchronously, using the Future to signal to the client when the message has been sent. + * + * @param text The text message to send + * * @return A Future that signals when the message has been sent. */ Future<Void> sendText(String text); /** - * Send the message asynchronously, using the Future to signal to the client - * when the message has been sent. - * @param data The text message to send + * Send the message asynchronously, using the Future to signal to the client when the message has been sent. + * + * @param data The text message to send + * * @return A Future that signals when the message has been sent. + * * @throws IllegalArgumentException if {@code data} is {@code null}. */ Future<Void> sendBinary(ByteBuffer data); /** - * Send the message asynchronously, using the SendHandler to signal to the - * client when the message has been sent. - * @param data The text message to send - * @param completion Used to signal to the client when the message has - * been sent - * @throws IllegalArgumentException if {@code data} or {@code completion} - * is {@code null}. + * Send the message asynchronously, using the SendHandler to signal to the client when the message has been + * sent. + * + * @param data The text message to send + * @param completion Used to signal to the client when the message has been sent + * + * @throws IllegalArgumentException if {@code data} or {@code completion} is {@code null}. */ void sendBinary(ByteBuffer data, SendHandler completion); /** - * Encodes object as a message and sends it asynchronously, using the - * Future to signal to the client when the message has been sent. - * @param obj The object to be sent. + * Encodes object as a message and sends it asynchronously, using the Future to signal to the client when the + * message has been sent. + * + * @param obj The object to be sent. + * * @return A Future that signals when the message has been sent. + * * @throws IllegalArgumentException if {@code obj} is {@code null}. */ Future<Void> sendObject(Object obj); /** - * Encodes object as a message and sends it asynchronously, using the - * SendHandler to signal to the client when the message has been sent. - * @param obj The object to be sent. - * @param completion Used to signal to the client when the message has - * been sent - * @throws IllegalArgumentException if {@code obj} or - * {@code completion} is {@code null}. + * Encodes object as a message and sends it asynchronously, using the SendHandler to signal to the client when + * the message has been sent. + * + * @param obj The object to be sent. + * @param completion Used to signal to the client when the message has been sent + * + * @throws IllegalArgumentException if {@code obj} or {@code completion} is {@code null}. */ void sendObject(Object obj, SendHandler completion); @@ -109,48 +113,45 @@ public interface RemoteEndpoint { /** * Send the message, blocking until the message is sent. - * @param text The text message to send. + * + * @param text The text message to send. + * * @throws IllegalArgumentException if {@code text} is {@code null}. - * @throws IOException if an I/O error occurs during the sending of the - * message. + * @throws IOException if an I/O error occurs during the sending of the message. */ void sendText(String text) throws IOException; /** * Send the message, blocking until the message is sent. - * @param data The binary message to send + * + * @param data The binary message to send + * * @throws IllegalArgumentException if {@code data} is {@code null}. - * @throws IOException if an I/O error occurs during the sending of the - * message. + * @throws IOException if an I/O error occurs during the sending of the message. */ void sendBinary(ByteBuffer data) throws IOException; /** - * Sends part of a text message to the remote endpoint. Once the first part - * of a message has been sent, no other text or binary messages may be sent - * until all remaining parts of this message have been sent. + * Sends part of a text message to the remote endpoint. Once the first part of a message has been sent, no other + * text or binary messages may be sent until all remaining parts of this message have been sent. + * + * @param fragment The partial message to send + * @param isLast <code>true</code> if this is the last part of the message, otherwise <code>false</code> * - * @param fragment The partial message to send - * @param isLast <code>true</code> if this is the last part of the - * message, otherwise <code>false</code> * @throws IllegalArgumentException if {@code fragment} is {@code null}. - * @throws IOException if an I/O error occurs during the sending of the - * message. + * @throws IOException if an I/O error occurs during the sending of the message. */ void sendText(String fragment, boolean isLast) throws IOException; /** - * Sends part of a binary message to the remote endpoint. Once the first - * part of a message has been sent, no other text or binary messages may be - * sent until all remaining parts of this message have been sent. - * - * @param partialByte The partial message to send - * @param isLast <code>true</code> if this is the last part of the - * message, otherwise <code>false</code> - * @throws IllegalArgumentException if {@code partialByte} is - * {@code null}. - * @throws IOException if an I/O error occurs during the sending of the - * message. + * Sends part of a binary message to the remote endpoint. Once the first part of a message has been sent, no + * other text or binary messages may be sent until all remaining parts of this message have been sent. + * + * @param partialByte The partial message to send + * @param isLast <code>true</code> if this is the last part of the message, otherwise <code>false</code> + * + * @throws IllegalArgumentException if {@code partialByte} is {@code null}. + * @throws IOException if an I/O error occurs during the sending of the message. */ void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException; @@ -160,70 +161,63 @@ public interface RemoteEndpoint { /** * Encodes object as a message and sends it to the remote endpoint. - * @param data The object to be sent. - * @throws EncodeException if there was a problem encoding the - * {@code data} object as a websocket message. + * + * @param data The object to be sent. + * + * @throws EncodeException if there was a problem encoding the {@code data} object as a websocket + * message. * @throws IllegalArgumentException if {@code data} is {@code null}. - * @throws IOException if an I/O error occurs during the sending of the - * message. + * @throws IOException if an I/O error occurs during the sending of the message. */ void sendObject(Object data) throws IOException, EncodeException; } + /** - * Enable or disable the batching of outgoing messages for this endpoint. If - * batching is disabled when it was previously enabled then this method will - * block until any currently batched messages have been written. + * Enable or disable the batching of outgoing messages for this endpoint. If batching is disabled when it was + * previously enabled then this method will block until any currently batched messages have been written. + * + * @param batchingAllowed New setting * - * @param batchingAllowed New setting - * @throws IOException If changing the value resulted in a call to - * {@link #flushBatch()} and that call threw an - * {@link IOException}. + * @throws IOException If changing the value resulted in a call to {@link #flushBatch()} and that call threw an + * {@link IOException}. */ void setBatchingAllowed(boolean batchingAllowed) throws IOException; /** * Obtains the current batching status of the endpoint. * - * @return <code>true</code> if batching is enabled, otherwise - * <code>false</code>. + * @return <code>true</code> if batching is enabled, otherwise <code>false</code>. */ boolean getBatchingAllowed(); /** - * Flush any currently batched messages to the remote endpoint. This method - * will block until the flush completes. + * Flush any currently batched messages to the remote endpoint. This method will block until the flush completes. * * @throws IOException If an I/O error occurs while flushing */ void flushBatch() throws IOException; /** - * Send a ping message blocking until the message has been sent. Note that - * if a message is in the process of being sent asynchronously, this method - * will block until that message and this ping has been sent. + * Send a ping message blocking until the message has been sent. Note that if a message is in the process of being + * sent asynchronously, this method will block until that message and this ping has been sent. * - * @param applicationData The payload for the ping message + * @param applicationData The payload for the ping message * - * @throws IOException If an I/O error occurs while sending the ping - * @throws IllegalArgumentException if the applicationData is too large for - * a control message (max 125 bytes) + * @throws IOException If an I/O error occurs while sending the ping + * @throws IllegalArgumentException if the applicationData is too large for a control message (max 125 bytes) */ - void sendPing(ByteBuffer applicationData) - throws IOException, IllegalArgumentException; + void sendPing(ByteBuffer applicationData) throws IOException, IllegalArgumentException; /** - * Send a pong message blocking until the message has been sent. Note that - * if a message is in the process of being sent asynchronously, this method - * will block until that message and this pong has been sent. + * Send a pong message blocking until the message has been sent. Note that if a message is in the process of being + * sent asynchronously, this method will block until that message and this pong has been sent. * - * @param applicationData The payload for the pong message + * @param applicationData The payload for the pong message * - * @throws IOException If an I/O error occurs while sending the pong - * @throws IllegalArgumentException if the applicationData is too large for - * a control message (max 125 bytes) + * @throws IOException If an I/O error occurs while sending the pong + * @throws IllegalArgumentException if the applicationData is too large for a control message (max 125 bytes) */ - void sendPong(ByteBuffer applicationData) - throws IOException, IllegalArgumentException; + void sendPong(ByteBuffer applicationData) throws IOException, IllegalArgumentException; } diff --git a/java/javax/websocket/SendResult.java b/java/javax/websocket/SendResult.java index a3797d5bb4..6bdf3659e7 100644 --- a/java/javax/websocket/SendResult.java +++ b/java/javax/websocket/SendResult.java @@ -26,7 +26,7 @@ public final class SendResult { } public SendResult() { - this (null); + this(null); } public Throwable getException() { diff --git a/java/javax/websocket/Session.java b/java/javax/websocket/Session.java index eea15e5be8..539fe7babc 100644 --- a/java/javax/websocket/Session.java +++ b/java/javax/websocket/Session.java @@ -28,24 +28,21 @@ public interface Session extends Closeable { /** * Get the container that created this session. + * * @return the container that created this session. */ WebSocketContainer getContainer(); /** - * Registers a {@link MessageHandler} for incoming messages. Only one - * {@link MessageHandler} may be registered for each message type (text, - * binary, pong). The message type will be derived at runtime from the - * provided {@link MessageHandler} instance. It is not always possible to do - * this so it is better to use - * {@link #addMessageHandler(Class, javax.websocket.MessageHandler.Partial)} - * or + * Registers a {@link MessageHandler} for incoming messages. Only one {@link MessageHandler} may be registered for + * each message type (text, binary, pong). The message type will be derived at runtime from the provided + * {@link MessageHandler} instance. It is not always possible to do this so it is better to use + * {@link #addMessageHandler(Class, javax.websocket.MessageHandler.Partial)} or * {@link #addMessageHandler(Class, javax.websocket.MessageHandler.Whole)}. * - * @param handler The message handler for a incoming message + * @param handler The message handler for a incoming message * - * @throws IllegalStateException If a message handler has already been - * registered for the associated message type + * @throws IllegalStateException If a message handler has already been registered for the associated message type */ void addMessageHandler(MessageHandler handler) throws IllegalStateException; @@ -65,38 +62,44 @@ public interface Session extends Closeable { /** * Get the idle timeout for this session. - * @return The current idle timeout for this session in milliseconds. Zero - * or negative values indicate an infinite timeout. + * + * @return The current idle timeout for this session in milliseconds. Zero or negative values indicate an infinite + * timeout. */ long getMaxIdleTimeout(); /** * Set the idle timeout for this session. - * @param timeout The new idle timeout for this session in milliseconds. - * Zero or negative values indicate an infinite timeout. + * + * @param timeout The new idle timeout for this session in milliseconds. Zero or negative values indicate an + * infinite timeout. */ void setMaxIdleTimeout(long timeout); /** * Set the current maximum buffer size for binary messages. + * * @param max The new maximum buffer size in bytes */ void setMaxBinaryMessageBufferSize(int max); /** * Get the current maximum buffer size for binary messages. + * * @return The current maximum buffer size in bytes */ int getMaxBinaryMessageBufferSize(); /** * Set the maximum buffer size for text messages. + * * @param max The new maximum buffer size in characters. */ void setMaxTextMessageBufferSize(int max); /** * Get the maximum buffer size for text messages. + * * @return The maximum buffer size in characters. */ int getMaxTextMessageBufferSize(); @@ -106,31 +109,29 @@ public interface Session extends Closeable { RemoteEndpoint.Basic getBasicRemote(); /** - * Provides a unique identifier for the session. This identifier should not - * be relied upon to be generated from a secure random source. + * Provides a unique identifier for the session. This identifier should not be relied upon to be generated from a + * secure random source. + * * @return A unique identifier for the session. */ String getId(); /** * Close the connection to the remote end point using the code - * {@link javax.websocket.CloseReason.CloseCodes#NORMAL_CLOSURE} and an - * empty reason phrase. + * {@link javax.websocket.CloseReason.CloseCodes#NORMAL_CLOSURE} and an empty reason phrase. * - * @throws IOException if an I/O error occurs while the WebSocket session is - * being closed. + * @throws IOException if an I/O error occurs while the WebSocket session is being closed. */ @Override void close() throws IOException; /** - * Close the connection to the remote end point using the specified code - * and reason phrase. + * Close the connection to the remote end point using the specified code and reason phrase. + * * @param closeReason The reason the WebSocket session is being closed. * - * @throws IOException if an I/O error occurs while the WebSocket session is - * being closed. + * @throws IOException if an I/O error occurs while the WebSocket session is being closed. */ void close(CloseReason closeReason) throws IOException; @@ -140,54 +141,44 @@ public interface Session extends Closeable { String getQueryString(); - Map<String,String> getPathParameters(); + Map<String, String> getPathParameters(); - Map<String,Object> getUserProperties(); + Map<String, Object> getUserProperties(); Principal getUserPrincipal(); /** - * Obtain the set of open sessions associated with the same local endpoint - * as this session. + * Obtain the set of open sessions associated with the same local endpoint as this session. * - * @return The set of currently open sessions for the local endpoint that - * this session is associated with. + * @return The set of currently open sessions for the local endpoint that this session is associated with. */ Set<Session> getOpenSessions(); /** - * Registers a {@link MessageHandler} for partial incoming messages. Only - * one {@link MessageHandler} may be registered for each message type (text - * or binary, pong messages are never presented as partial messages). + * Registers a {@link MessageHandler} for partial incoming messages. Only one {@link MessageHandler} may be + * registered for each message type (text or binary, pong messages are never presented as partial messages). * - * @param <T> The type of message that the given handler is intended - * for - * @param clazz The Class that implements T - * @param handler The message handler for a incoming message + * @param <T> The type of message that the given handler is intended for + * @param clazz The Class that implements T + * @param handler The message handler for a incoming message * - * @throws IllegalStateException If a message handler has already been - * registered for the associated message type + * @throws IllegalStateException If a message handler has already been registered for the associated message type * * @since WebSocket 1.1 */ - <T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler) - throws IllegalStateException; + <T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler) throws IllegalStateException; /** - * Registers a {@link MessageHandler} for whole incoming messages. Only - * one {@link MessageHandler} may be registered for each message type (text, - * binary, pong). + * Registers a {@link MessageHandler} for whole incoming messages. Only one {@link MessageHandler} may be registered + * for each message type (text, binary, pong). * - * @param <T> The type of message that the given handler is intended - * for - * @param clazz The Class that implements T - * @param handler The message handler for a incoming message + * @param <T> The type of message that the given handler is intended for + * @param clazz The Class that implements T + * @param handler The message handler for a incoming message * - * @throws IllegalStateException If a message handler has already been - * registered for the associated message type + * @throws IllegalStateException If a message handler has already been registered for the associated message type * * @since WebSocket 1.1 */ - <T> void addMessageHandler(Class<T> clazz, MessageHandler.Whole<T> handler) - throws IllegalStateException; + <T> void addMessageHandler(Class<T> clazz, MessageHandler.Whole<T> handler) throws IllegalStateException; } diff --git a/java/javax/websocket/WebSocketContainer.java b/java/javax/websocket/WebSocketContainer.java index f2da3e4327..ac5b063f98 100644 --- a/java/javax/websocket/WebSocketContainer.java +++ b/java/javax/websocket/WebSocketContainer.java @@ -24,108 +24,100 @@ public interface WebSocketContainer { /** * Get the default timeout for sending a message asynchronously. - * @return The current default timeout in milliseconds. A non-positive value - * means an infinite timeout. + * + * @return The current default timeout in milliseconds. A non-positive value means an infinite timeout. */ long getDefaultAsyncSendTimeout(); /** * Set the default timeout for sending a message asynchronously. - * @param timeout The new default timeout in milliseconds. A non-positive - * value means an infinite timeout. + * + * @param timeout The new default timeout in milliseconds. A non-positive value means an infinite timeout. */ void setAsyncSendTimeout(long timeout); - Session connectToServer(Object endpoint, URI path) - throws DeploymentException, IOException; + Session connectToServer(Object endpoint, URI path) throws DeploymentException, IOException; - Session connectToServer(Class<?> annotatedEndpointClass, URI path) - throws DeploymentException, IOException; + Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException, IOException; /** * Creates a new connection to the WebSocket. * - * @param endpoint - * The endpoint instance that will handle responses from the - * server - * @param clientEndpointConfiguration - * Used to configure the new connection - * @param path - * The full URL of the WebSocket endpoint to connect to + * @param endpoint The endpoint instance that will handle responses from the server + * @param clientEndpointConfiguration Used to configure the new connection + * @param path The full URL of the WebSocket endpoint to connect to * * @return The WebSocket session for the connection * - * @throws DeploymentException If the connection cannot be established - * @throws IOException If an I/O occurred while trying to establish the - * connection + * @throws DeploymentException If the connection cannot be established + * @throws IOException If an I/O occurred while trying to establish the connection */ - Session connectToServer(Endpoint endpoint, - ClientEndpointConfig clientEndpointConfiguration, URI path) + Session connectToServer(Endpoint endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path) throws DeploymentException, IOException; /** * Creates a new connection to the WebSocket. * - * @param endpoint - * An instance of this class will be created to handle responses - * from the server - * @param clientEndpointConfiguration - * Used to configure the new connection - * @param path - * The full URL of the WebSocket endpoint to connect to + * @param endpoint An instance of this class will be created to handle responses from the server + * @param clientEndpointConfiguration Used to configure the new connection + * @param path The full URL of the WebSocket endpoint to connect to * * @return The WebSocket session for the connection * - * @throws DeploymentException If the connection cannot be established - * @throws IOException If an I/O occurred while trying to establish the - * connection + * @throws DeploymentException If the connection cannot be established + * @throws IOException If an I/O occurred while trying to establish the connection */ - Session connectToServer(Class<? extends Endpoint> endpoint, - ClientEndpointConfig clientEndpointConfiguration, URI path) - throws DeploymentException, IOException; + Session connectToServer(Class<? extends Endpoint> endpoint, ClientEndpointConfig clientEndpointConfiguration, + URI path) throws DeploymentException, IOException; /** * Get the current default session idle timeout. - * @return The current default session idle timeout in milliseconds. Zero or - * negative values indicate an infinite timeout. + * + * @return The current default session idle timeout in milliseconds. Zero or negative values indicate an infinite + * timeout. */ long getDefaultMaxSessionIdleTimeout(); /** * Set the default session idle timeout. - * @param timeout The new default session idle timeout in milliseconds. Zero - * or negative values indicate an infinite timeout. + * + * @param timeout The new default session idle timeout in milliseconds. Zero or negative values indicate an infinite + * timeout. */ void setDefaultMaxSessionIdleTimeout(long timeout); /** * Get the default maximum buffer size for binary messages. + * * @return The current default maximum buffer size in bytes */ int getDefaultMaxBinaryMessageBufferSize(); /** * Set the default maximum buffer size for binary messages. + * * @param max The new default maximum buffer size in bytes */ void setDefaultMaxBinaryMessageBufferSize(int max); /** * Get the default maximum buffer size for text messages. + * * @return The current default maximum buffer size in characters */ int getDefaultMaxTextMessageBufferSize(); /** * Set the default maximum buffer size for text messages. + * * @param max The new default maximum buffer size in characters */ void setDefaultMaxTextMessageBufferSize(int max); /** * Get the installed extensions. - * @return The set of extensions that are supported by this WebSocket - * implementation. + * + * @return The set of extensions that are supported by this WebSocket implementation. */ Set<Extension> getInstalledExtensions(); } diff --git a/java/javax/websocket/server/DefaultServerEndpointConfig.java b/java/javax/websocket/server/DefaultServerEndpointConfig.java index 422cbda422..a47d5f91aa 100644 --- a/java/javax/websocket/server/DefaultServerEndpointConfig.java +++ b/java/javax/websocket/server/DefaultServerEndpointConfig.java @@ -36,14 +36,11 @@ final class DefaultServerEndpointConfig implements ServerEndpointConfig { private final List<Class<? extends Encoder>> encoders; private final List<Class<? extends Decoder>> decoders; private final Configurator serverEndpointConfigurator; - private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String, Object> userProperties = new ConcurrentHashMap<>(); - DefaultServerEndpointConfig( - Class<?> endpointClass, String path, - List<String> subprotocols, List<Extension> extensions, - List<Class<? extends Encoder>> encoders, - List<Class<? extends Decoder>> decoders, - Configurator serverEndpointConfigurator) { + DefaultServerEndpointConfig(Class<?> endpointClass, String path, List<String> subprotocols, + List<Extension> extensions, List<Class<? extends Encoder>> encoders, + List<Class<? extends Decoder>> decoders, Configurator serverEndpointConfigurator) { this.endpointClass = endpointClass; this.path = path; this.subprotocols = subprotocols; diff --git a/java/javax/websocket/server/HandshakeRequest.java b/java/javax/websocket/server/HandshakeRequest.java index 49acfdfd99..6477a21b06 100644 --- a/java/javax/websocket/server/HandshakeRequest.java +++ b/java/javax/websocket/server/HandshakeRequest.java @@ -29,9 +29,9 @@ public interface HandshakeRequest { String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key"; String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol"; String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version"; - String SEC_WEBSOCKET_EXTENSIONS= "Sec-WebSocket-Extensions"; + String SEC_WEBSOCKET_EXTENSIONS = "Sec-WebSocket-Extensions"; - Map<String,List<String>> getHeaders(); + Map<String, List<String>> getHeaders(); Principal getUserPrincipal(); @@ -40,10 +40,10 @@ public interface HandshakeRequest { boolean isUserInRole(String role); /** - * Get the HTTP Session object associated with this request. Object is used - * to avoid a direct dependency on the Servlet API. - * @return The javax.servlet.http.HttpSession object associated with this - * request, if any. + * Get the HTTP Session object associated with this request. Object is used to avoid a direct dependency on the + * Servlet API. + * + * @return The javax.servlet.http.HttpSession object associated with this request, if any. */ Object getHttpSession(); diff --git a/java/javax/websocket/server/PathParam.java b/java/javax/websocket/server/PathParam.java index ff1d085ed1..df9833c8c2 100644 --- a/java/javax/websocket/server/PathParam.java +++ b/java/javax/websocket/server/PathParam.java @@ -22,9 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Used to annotate method parameters on POJO endpoints the the {@link - * ServerEndpoint} has been defined with a {@link ServerEndpoint#value()} that - * uses a URI template. + * Used to annotate method parameters on POJO endpoints the the {@link ServerEndpoint} has been defined with a + * {@link ServerEndpoint#value()} that uses a URI template. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) diff --git a/java/javax/websocket/server/ServerApplicationConfig.java b/java/javax/websocket/server/ServerApplicationConfig.java index b91f1c4397..5f2a0971da 100644 --- a/java/javax/websocket/server/ServerApplicationConfig.java +++ b/java/javax/websocket/server/ServerApplicationConfig.java @@ -21,31 +21,26 @@ import java.util.Set; import javax.websocket.Endpoint; /** - * Applications may provide an implementation of this interface to filter the - * discovered WebSocket endpoints that are deployed. Implementations of this - * class will be discovered via an ServletContainerInitializer scan. + * Applications may provide an implementation of this interface to filter the discovered WebSocket endpoints that are + * deployed. Implementations of this class will be discovered via an ServletContainerInitializer scan. */ public interface ServerApplicationConfig { /** - * Enables applications to filter the discovered implementations of - * {@link ServerEndpointConfig}. + * Enables applications to filter the discovered implementations of {@link ServerEndpointConfig}. * - * @param scanned The {@link Endpoint} implementations found in the - * application - * @return The set of configurations for the endpoint the application - * wishes to deploy + * @param scanned The {@link Endpoint} implementations found in the application + * + * @return The set of configurations for the endpoint the application wishes to deploy */ - Set<ServerEndpointConfig> getEndpointConfigs( - Set<Class<? extends Endpoint>> scanned); + Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> scanned); /** - * Enables applications to filter the discovered classes annotated with - * {@link ServerEndpoint}. + * Enables applications to filter the discovered classes annotated with {@link ServerEndpoint}. + * + * @param scanned The POJOs annotated with {@link ServerEndpoint} found in the application * - * @param scanned The POJOs annotated with {@link ServerEndpoint} found in - * the application - * @return The set of POJOs the application wishes to deploy + * @return The set of POJOs the application wishes to deploy */ Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned); } diff --git a/java/javax/websocket/server/ServerEndpoint.java b/java/javax/websocket/server/ServerEndpoint.java index d42bce9eac..66f75d6749 100644 --- a/java/javax/websocket/server/ServerEndpoint.java +++ b/java/javax/websocket/server/ServerEndpoint.java @@ -30,8 +30,8 @@ public @interface ServerEndpoint { /** * URI or URI-template that the annotated class should be mapped to. - * @return The URI or URI-template that the annotated class should be mapped - * to. + * + * @return The URI or URI-template that the annotated class should be mapped to. */ String value(); @@ -41,6 +41,5 @@ public @interface ServerEndpoint { Class<? extends Encoder>[] encoders() default {}; - Class<? extends ServerEndpointConfig.Configurator> configurator() - default ServerEndpointConfig.Configurator.class; + Class<? extends ServerEndpointConfig.Configurator> configurator() default ServerEndpointConfig.Configurator.class; } diff --git a/java/javax/websocket/server/ServerEndpointConfig.java b/java/javax/websocket/server/ServerEndpointConfig.java index 92a36b4846..879c104b65 100644 --- a/java/javax/websocket/server/ServerEndpointConfig.java +++ b/java/javax/websocket/server/ServerEndpointConfig.java @@ -30,17 +30,17 @@ import javax.websocket.Extension; import javax.websocket.HandshakeResponse; /** - * Provides configuration information for WebSocket endpoints published to a - * server. Applications may provide their own implementation or use - * {@link Builder}. + * Provides configuration information for WebSocket endpoints published to a server. Applications may provide their own + * implementation or use {@link Builder}. */ public interface ServerEndpointConfig extends EndpointConfig { Class<?> getEndpointClass(); /** - * Returns the path at which this WebSocket server endpoint has been - * registered. It may be a path or a level 0 URI template. + * Returns the path at which this WebSocket server endpoint has been registered. It may be a path or a level 0 URI + * template. + * * @return The registered path */ String getPath(); @@ -54,26 +54,21 @@ public interface ServerEndpointConfig extends EndpointConfig { final class Builder { - public static Builder create( - Class<?> endpointClass, String path) { + public static Builder create(Class<?> endpointClass, String path) { return new Builder(endpointClass, path); } private final Class<?> endpointClass; private final String path; - private List<Class<? extends Encoder>> encoders = - Collections.emptyList(); - private List<Class<? extends Decoder>> decoders = - Collections.emptyList(); + private List<Class<? extends Encoder>> encoders = Collections.emptyList(); + private List<Class<? extends Decoder>> decoders = Collections.emptyList(); private List<String> subprotocols = Collections.emptyList(); private List<Extension> extensions = Collections.emptyList(); - private Configurator configurator = - Configurator.fetchContainerDefaultConfigurator(); + private Configurator configurator = Configurator.fetchContainerDefaultConfigurator(); - private Builder(Class<?> endpointClass, - String path) { + private Builder(Class<?> endpointClass, String path) { if (endpointClass == null) { throw new IllegalArgumentException("Endpoint class may not be null"); } @@ -91,13 +86,12 @@ public interface ServerEndpointConfig extends EndpointConfig { } public ServerEndpointConfig build() { - return new DefaultServerEndpointConfig(endpointClass, path, - subprotocols, extensions, encoders, decoders, configurator); + return new DefaultServerEndpointConfig(endpointClass, path, subprotocols, extensions, encoders, decoders, + configurator); } - public Builder encoders( - List<Class<? extends Encoder>> encoders) { + public Builder encoders(List<Class<? extends Encoder>> encoders) { if (encoders == null || encoders.size() == 0) { this.encoders = Collections.emptyList(); } else { @@ -107,8 +101,7 @@ public interface ServerEndpointConfig extends EndpointConfig { } - public Builder decoders( - List<Class<? extends Decoder>> decoders) { + public Builder decoders(List<Class<? extends Decoder>> decoders) { if (decoders == null || decoders.size() == 0) { this.decoders = Collections.emptyList(); } else { @@ -118,8 +111,7 @@ public interface ServerEndpointConfig extends EndpointConfig { } - public Builder subprotocols( - List<String> subprotocols) { + public Builder subprotocols(List<String> subprotocols) { if (subprotocols == null || subprotocols.size() == 0) { this.subprotocols = Collections.emptyList(); } else { @@ -129,8 +121,7 @@ public interface ServerEndpointConfig extends EndpointConfig { } - public Builder extensions( - List<Extension> extensions) { + public Builder extensions(List<Extension> extensions) { if (extensions == null || extensions.size() == 0) { this.extensions = Collections.emptyList(); } else { @@ -156,8 +147,7 @@ public interface ServerEndpointConfig extends EndpointConfig { private static volatile Configurator defaultImpl = null; private static final Object defaultImplLock = new Object(); - private static final String DEFAULT_IMPL_CLASSNAME = - "org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator"; + private static final String DEFAULT_IMPL_CLASSNAME = "org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator"; static Configurator fetchContainerDefaultConfigurator() { if (defaultImpl == null) { @@ -166,8 +156,7 @@ public interface ServerEndpointConfig extends EndpointConfig { if (System.getSecurityManager() == null) { defaultImpl = loadDefault(); } else { - defaultImpl = - AccessController.doPrivileged(new PrivilegedLoadDefault()); + defaultImpl = AccessController.doPrivileged(new PrivilegedLoadDefault()); } } } @@ -179,8 +168,7 @@ public interface ServerEndpointConfig extends EndpointConfig { private static Configurator loadDefault() { Configurator result = null; - ServiceLoader<Configurator> serviceLoader = - ServiceLoader.load(Configurator.class); + ServiceLoader<Configurator> serviceLoader = ServiceLoader.load(Configurator.class); Iterator<Configurator> iter = serviceLoader.iterator(); while (result == null && iter.hasNext()) { @@ -191,12 +179,9 @@ public interface ServerEndpointConfig extends EndpointConfig { if (result == null) { try { @SuppressWarnings("unchecked") - Class<Configurator> clazz = - (Class<Configurator>) Class.forName( - DEFAULT_IMPL_CLASSNAME); + Class<Configurator> clazz = (Class<Configurator>) Class.forName(DEFAULT_IMPL_CLASSNAME); result = clazz.getConstructor().newInstance(); - } catch (ReflectiveOperationException | IllegalArgumentException | - SecurityException e) { + } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { // No options left. Just return null. } } @@ -213,13 +198,11 @@ public interface ServerEndpointConfig extends EndpointConfig { } - public String getNegotiatedSubprotocol(List<String> supported, - List<String> requested) { + public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) { return fetchContainerDefaultConfigurator().getNegotiatedSubprotocol(supported, requested); } - public List<Extension> getNegotiatedExtensions(List<Extension> installed, - List<Extension> requested) { + public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) { return fetchContainerDefaultConfigurator().getNegotiatedExtensions(installed, requested); } @@ -227,15 +210,12 @@ public interface ServerEndpointConfig extends EndpointConfig { return fetchContainerDefaultConfigurator().checkOrigin(originHeaderValue); } - public void modifyHandshake(ServerEndpointConfig sec, - HandshakeRequest request, HandshakeResponse response) { + public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) { fetchContainerDefaultConfigurator().modifyHandshake(sec, request, response); } - public <T extends Object> T getEndpointInstance(Class<T> clazz) - throws InstantiationException { - return fetchContainerDefaultConfigurator().getEndpointInstance( - clazz); + public <T extends Object> T getEndpointInstance(Class<T> clazz) throws InstantiationException { + return fetchContainerDefaultConfigurator().getEndpointInstance(clazz); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org