This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 5a72e72caa Code clean-up - formatting. No functional change. 5a72e72caa is described below commit 5a72e72caa5241a0c89fb1e484f0b8a439f53023 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Aug 29 12:03:30 2025 +0100 Code clean-up - formatting. No functional change. --- .../tomcat/websocket/AsyncChannelGroupUtil.java | 4 +- .../tomcat/websocket/AsyncChannelWrapper.java | 4 +- .../websocket/AsyncChannelWrapperNonSecure.java | 4 +- .../websocket/AsyncChannelWrapperSecure.java | 34 ++++++++-------- .../org/apache/tomcat/websocket/Authenticator.java | 4 +- .../tomcat/websocket/BasicAuthenticator.java | 2 +- java/org/apache/tomcat/websocket/Constants.java | 27 +++++++------ .../tomcat/websocket/DigestAuthenticator.java | 5 ++- .../apache/tomcat/websocket/PerMessageDeflate.java | 4 +- java/org/apache/tomcat/websocket/Util.java | 33 ++++++++-------- .../org/apache/tomcat/websocket/WsFrameClient.java | 4 +- .../tomcat/websocket/WsHandshakeResponse.java | 8 ++-- .../tomcat/websocket/WsRemoteEndpointImplBase.java | 21 +++++----- java/org/apache/tomcat/websocket/WsSession.java | 33 ++++++++-------- .../tomcat/websocket/WsWebSocketContainer.java | 45 +++++++++++----------- 15 files changed, 118 insertions(+), 114 deletions(-) diff --git a/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java b/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java index dc6ec3ff2a..0926f2b857 100644 --- a/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java +++ b/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java @@ -81,8 +81,8 @@ public class AsyncChannelGroupUtil { // These are the same settings as the default // AsynchronousChannelGroup int initialSize = Runtime.getRuntime().availableProcessors(); - ExecutorService executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, - TimeUnit.SECONDS, new SynchronousQueue<>(), new AsyncIOThreadFactory()); + ExecutorService executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, + new SynchronousQueue<>(), new AsyncIOThreadFactory()); try { return AsynchronousChannelGroup.withCachedThreadPool(executorService, initialSize); diff --git a/java/org/apache/tomcat/websocket/AsyncChannelWrapper.java b/java/org/apache/tomcat/websocket/AsyncChannelWrapper.java index 978dc3fa73..d5d87a858d 100644 --- a/java/org/apache/tomcat/websocket/AsyncChannelWrapper.java +++ b/java/org/apache/tomcat/websocket/AsyncChannelWrapper.java @@ -33,12 +33,12 @@ public interface AsyncChannelWrapper { Future<Integer> read(ByteBuffer dst); - <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, B> handler); + <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler); Future<Integer> write(ByteBuffer src); <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, - CompletionHandler<Long, B> handler); + CompletionHandler<Long,B> handler); void close(); diff --git a/java/org/apache/tomcat/websocket/AsyncChannelWrapperNonSecure.java b/java/org/apache/tomcat/websocket/AsyncChannelWrapperNonSecure.java index 31a0e29cb4..d9aee3d0b1 100644 --- a/java/org/apache/tomcat/websocket/AsyncChannelWrapperNonSecure.java +++ b/java/org/apache/tomcat/websocket/AsyncChannelWrapperNonSecure.java @@ -46,7 +46,7 @@ public class AsyncChannelWrapperNonSecure implements AsyncChannelWrapper { } @Override - public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, B> handler) { + public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler) { socketChannel.read(dst, attachment, handler); } @@ -57,7 +57,7 @@ public class AsyncChannelWrapperNonSecure implements AsyncChannelWrapper { @Override public <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, - A attachment, CompletionHandler<Long, B> handler) { + A attachment, CompletionHandler<Long,B> handler) { socketChannel.write(srcs, offset, length, timeout, unit, attachment, handler); } diff --git a/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java b/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java index 395ad11852..7ad581ddd4 100644 --- a/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java +++ b/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java @@ -73,7 +73,7 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { @Override public Future<Integer> read(ByteBuffer dst) { - WrapperFuture<Integer, Void> future = new WrapperFuture<>(); + WrapperFuture<Integer,Void> future = new WrapperFuture<>(); if (!reading.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString("asyncChannelWrapperSecure.concurrentRead")); @@ -87,9 +87,9 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { } @Override - public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, B> handler) { + public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler) { - WrapperFuture<Integer, B> future = new WrapperFuture<>(handler, attachment); + WrapperFuture<Integer,B> future = new WrapperFuture<>(handler, attachment); if (!reading.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString("asyncChannelWrapperSecure.concurrentRead")); @@ -103,7 +103,7 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { @Override public Future<Integer> write(ByteBuffer src) { - WrapperFuture<Long, Void> inner = new WrapperFuture<>(); + WrapperFuture<Long,Void> inner = new WrapperFuture<>(); if (!writing.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString("asyncChannelWrapperSecure.concurrentWrite")); @@ -118,9 +118,9 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { @Override public <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, - A attachment, CompletionHandler<Long, B> handler) { + A attachment, CompletionHandler<Long,B> handler) { - WrapperFuture<Long, B> future = new WrapperFuture<>(handler, attachment); + WrapperFuture<Long,B> future = new WrapperFuture<>(handler, attachment); if (!writing.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString("asyncChannelWrapperSecure.concurrentWrite")); @@ -148,7 +148,7 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { @Override public Future<Void> handshake() throws SSLException { - WrapperFuture<Void, Void> wFuture = new WrapperFuture<>(); + WrapperFuture<Void,Void> wFuture = new WrapperFuture<>(); Thread t = new WebSocketSslHandshakeThread(wFuture); t.start(); @@ -168,9 +168,9 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { private final ByteBuffer[] srcs; private final int offset; private final int length; - private final WrapperFuture<Long, ?> future; + private final WrapperFuture<Long,?> future; - WriteTask(ByteBuffer[] srcs, int offset, int length, WrapperFuture<Long, ?> future) { + WriteTask(ByteBuffer[] srcs, int offset, int length, WrapperFuture<Long,?> future) { this.srcs = srcs; this.future = future; this.offset = offset; @@ -239,9 +239,9 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { private class ReadTask implements Runnable { private final ByteBuffer dest; - private final WrapperFuture<Integer, ?> future; + private final WrapperFuture<Integer,?> future; - ReadTask(ByteBuffer dest, WrapperFuture<Integer, ?> future) { + ReadTask(ByteBuffer dest, WrapperFuture<Integer,?> future) { this.dest = dest; this.future = future; } @@ -324,8 +324,8 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { } else { future.fail(new IllegalStateException(sm.getString("asyncChannelWrapperSecure.wrongStateRead"))); } - } catch (RuntimeException | ReadBufferOverflowException | SSLException | EOFException | ExecutionException - | InterruptedException e) { + } catch (RuntimeException | ReadBufferOverflowException | SSLException | EOFException | ExecutionException | + InterruptedException e) { reading.set(false); future.fail(e); } @@ -335,12 +335,12 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { private class WebSocketSslHandshakeThread extends Thread { - private final WrapperFuture<Void, Void> hFuture; + private final WrapperFuture<Void,Void> hFuture; private HandshakeStatus handshakeStatus; private Status resultStatus; - WebSocketSslHandshakeThread(WrapperFuture<Void, Void> hFuture) { + WebSocketSslHandshakeThread(WrapperFuture<Void,Void> hFuture) { this.hFuture = hFuture; } @@ -427,7 +427,7 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { private static class WrapperFuture<T, A> implements Future<T> { - private final CompletionHandler<T, A> handler; + private final CompletionHandler<T,A> handler; private final A attachment; private volatile T result = null; @@ -438,7 +438,7 @@ public class AsyncChannelWrapperSecure implements AsyncChannelWrapper { this(null, null); } - WrapperFuture(CompletionHandler<T, A> handler, A attachment) { + WrapperFuture(CompletionHandler<T,A> handler, A attachment) { this.handler = handler; this.attachment = attachment; } diff --git a/java/org/apache/tomcat/websocket/Authenticator.java b/java/org/apache/tomcat/websocket/Authenticator.java index 20e6a7cd24..cdf20cfd06 100644 --- a/java/org/apache/tomcat/websocket/Authenticator.java +++ b/java/org/apache/tomcat/websocket/Authenticator.java @@ -66,10 +66,10 @@ public abstract class Authenticator { * * @return a map of authentication parameter names and values */ - public Map<String, String> parseAuthenticateHeader(String authenticateHeader) { + public Map<String,String> parseAuthenticateHeader(String authenticateHeader) { Matcher m = pattern.matcher(authenticateHeader); - Map<String, String> parameterMap = new HashMap<>(); + Map<String,String> parameterMap = new HashMap<>(); while (m.find()) { String key = m.group(1); diff --git a/java/org/apache/tomcat/websocket/BasicAuthenticator.java b/java/org/apache/tomcat/websocket/BasicAuthenticator.java index c8e63859f9..b669d2eb94 100644 --- a/java/org/apache/tomcat/websocket/BasicAuthenticator.java +++ b/java/org/apache/tomcat/websocket/BasicAuthenticator.java @@ -36,7 +36,7 @@ public class BasicAuthenticator extends Authenticator { validateUsername(userName); validatePassword(userPassword); - Map<String, String> parameterMap = parseAuthenticateHeader(authenticateHeader); + Map<String,String> parameterMap = parseAuthenticateHeader(authenticateHeader); String realm = parameterMap.get("realm"); validateRealm(userRealm, realm); diff --git a/java/org/apache/tomcat/websocket/Constants.java b/java/org/apache/tomcat/websocket/Constants.java index e2e37c2f92..c9d4414e93 100644 --- a/java/org/apache/tomcat/websocket/Constants.java +++ b/java/org/apache/tomcat/websocket/Constants.java @@ -41,8 +41,8 @@ public class Constants { static final byte INTERNAL_OPCODE_FLUSH = 0x18; // Buffers - static final int DEFAULT_BUFFER_SIZE = Integer - .getInteger("org.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE", 8 * 1024).intValue(); + static final int DEFAULT_BUFFER_SIZE = + Integer.getInteger("org.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE", 8 * 1024).intValue(); // Client connection /** @@ -108,8 +108,8 @@ public class Constants { public static final int PROXY_AUTHENTICATION_REQUIRED = 407; // Configuration for Origin header in client - static final String DEFAULT_ORIGIN_HEADER_VALUE = System - .getProperty("org.apache.tomcat.websocket.DEFAULT_ORIGIN_HEADER_VALUE"); + static final String DEFAULT_ORIGIN_HEADER_VALUE = + System.getProperty("org.apache.tomcat.websocket.DEFAULT_ORIGIN_HEADER_VALUE"); // Configuration for blocking sends public static final String BLOCKING_SEND_TIMEOUT_PROPERTY = "org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT"; @@ -122,7 +122,8 @@ public class Constants { public static final long DEFAULT_SESSION_CLOSE_TIMEOUT = TimeUnit.SECONDS.toMillis(30); // Configuration for session close timeout - public static final String ABNORMAL_SESSION_CLOSE_SEND_TIMEOUT_PROPERTY = "org.apache.tomcat.websocket.ABNORMAL_SESSION_CLOSE_SEND_TIMEOUT"; + public static final String ABNORMAL_SESSION_CLOSE_SEND_TIMEOUT_PROPERTY = + "org.apache.tomcat.websocket.ABNORMAL_SESSION_CLOSE_SEND_TIMEOUT"; // Default is 50 milliseconds - setting is in milliseconds public static final long DEFAULT_ABNORMAL_SESSION_CLOSE_SEND_TIMEOUT = 50; @@ -133,19 +134,21 @@ public class Constants { public static final String WRITE_IDLE_TIMEOUT_MS = "org.apache.tomcat.websocket.WRITE_IDLE_TIMEOUT_MS"; // Configuration for background processing checks intervals - static final int DEFAULT_PROCESS_PERIOD = Integer - .getInteger("org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD", 10).intValue(); + static final int DEFAULT_PROCESS_PERIOD = + Integer.getInteger("org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD", 10).intValue(); public static final String WS_AUTHENTICATION_USER_NAME = "org.apache.tomcat.websocket.WS_AUTHENTICATION_USER_NAME"; public static final String WS_AUTHENTICATION_PASSWORD = "org.apache.tomcat.websocket.WS_AUTHENTICATION_PASSWORD"; public static final String WS_AUTHENTICATION_REALM = "org.apache.tomcat.websocket.WS_AUTHENTICATION_REALM"; - public static final String WS_AUTHENTICATION_PROXY_USER_NAME = "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_USER_NAME"; - public static final String WS_AUTHENTICATION_PROXY_PASSWORD = "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_PASSWORD"; - public static final String WS_AUTHENTICATION_PROXY_REALM = "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_REALM"; + public static final String WS_AUTHENTICATION_PROXY_USER_NAME = + "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_USER_NAME"; + public static final String WS_AUTHENTICATION_PROXY_PASSWORD = + "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_PASSWORD"; + public static final String WS_AUTHENTICATION_PROXY_REALM = + "org.apache.tomcat.websocket.WS_AUTHENTICATION_PROXY_REALM"; - public static final List<Extension> INSTALLED_EXTENSIONS = - List.of(new WsExtension("permessage-deflate")); + public static final List<Extension> INSTALLED_EXTENSIONS = List.of(new WsExtension("permessage-deflate")); private Constants() { // Hide default constructor diff --git a/java/org/apache/tomcat/websocket/DigestAuthenticator.java b/java/org/apache/tomcat/websocket/DigestAuthenticator.java index 392cd97660..20a4ab9d54 100644 --- a/java/org/apache/tomcat/websocket/DigestAuthenticator.java +++ b/java/org/apache/tomcat/websocket/DigestAuthenticator.java @@ -46,7 +46,7 @@ public class DigestAuthenticator extends Authenticator { validateUsername(userName); validatePassword(userPassword); - Map<String, String> parameterMap = parseAuthenticateHeader(authenticateHeader); + Map<String,String> parameterMap = parseAuthenticateHeader(authenticateHeader); String realm = parameterMap.get("realm"); validateRealm(userRealm, realm); @@ -79,7 +79,8 @@ public class DigestAuthenticator extends Authenticator { try { challenge.append("response=\""); - challenge.append(calculateRequestDigest(requestUri, userName, userPassword, realm, nonce, messageQop, algorithm)); + challenge.append( + calculateRequestDigest(requestUri, userName, userPassword, realm, nonce, messageQop, algorithm)); challenge.append("\","); } diff --git a/java/org/apache/tomcat/websocket/PerMessageDeflate.java b/java/org/apache/tomcat/websocket/PerMessageDeflate.java index befd9666c0..803842b0c6 100644 --- a/java/org/apache/tomcat/websocket/PerMessageDeflate.java +++ b/java/org/apache/tomcat/websocket/PerMessageDeflate.java @@ -401,14 +401,14 @@ public class PerMessageDeflate implements Transformation { compressedPart = new MessagePart(false, getRsv(uncompressedPart), opCode, compressedPayload, uncompressedIntermediateHandler, uncompressedIntermediateHandler, blockingWriteTimeoutExpiry); - } else if (!fin && full/* note: needsInput is true here*/) { + } else if (!fin && full/* note: needsInput is true here */) { // Write buffer full and input message not fully read. // Output and get more data. compressedPart = new MessagePart(false, getRsv(uncompressedPart), opCode, compressedPayload, uncompressedIntermediateHandler, uncompressedIntermediateHandler, blockingWriteTimeoutExpiry); deflateRequired = false; - } else if (fin && full/* note: needsInput is true here*/) { + } else if (fin && full/* note: needsInput is true here */) { // Write buffer full. Input fully read. Deflater may be // in one of four states: // - output complete (just happened to align with end of diff --git a/java/org/apache/tomcat/websocket/Util.java b/java/org/apache/tomcat/websocket/Util.java index 7f80f8ed3b..127e25f6b8 100644 --- a/java/org/apache/tomcat/websocket/Util.java +++ b/java/org/apache/tomcat/websocket/Util.java @@ -222,8 +222,8 @@ public class Util { // the interface of interest // Map that unknown type to the generic types defined in this class ParameterizedType superClassType = (ParameterizedType) clazz.getGenericSuperclass(); - TypeResult result = getTypeParameter(clazz, - superClassType.getActualTypeArguments()[superClassTypeResult.getIndex()]); + TypeResult result = + getTypeParameter(clazz, superClassType.getActualTypeArguments()[superClassTypeResult.getIndex()]); result.incrementDimension(superClassTypeResult.getDimension()); if (result.getClazz() != null && result.getDimension() > 0) { superClassTypeResult = result; @@ -285,8 +285,8 @@ public class Util { return true; } else { return clazz.equals(Boolean.class) || clazz.equals(Byte.class) || clazz.equals(Character.class) || - clazz.equals(Double.class) || clazz.equals(Float.class) || clazz.equals(Integer.class) || - clazz.equals(Long.class) || clazz.equals(Short.class); + clazz.equals(Double.class) || clazz.equals(Float.class) || clazz.equals(Integer.class) || + clazz.equals(Long.class) || clazz.equals(Short.class); } } @@ -343,8 +343,8 @@ public class Util { // Don't need this instance, so destroy it instanceManager.destroyInstance(instance); } - } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException - | NamingException e) { + } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException | + NamingException e) { throw new DeploymentException( sm.getString("pojoMethodMapping.invalidDecoder", decoderClazz.getName()), e); } @@ -378,13 +378,16 @@ public class Util { // the types expected by the frame handling code } else if (byte[].class.isAssignableFrom(target)) { boolean whole = MessageHandler.Whole.class.isAssignableFrom(listener.getClass()); - MessageHandlerResult result = new MessageHandlerResult(whole - ? new PojoMessageHandlerWholeBinary(listener, getOnMessageMethod(listener), session, endpointConfig, - matchDecoders(target, endpointConfig, true, ((WsSession) session).getInstanceManager()), - new Object[1], 0, true, -1, false, -1) - : new PojoMessageHandlerPartialBinary(listener, getOnMessagePartialMethod(listener), session, - new Object[2], 0, true, 1, -1, -1), - MessageHandlerResultType.BINARY); + MessageHandlerResult result = + new MessageHandlerResult(whole ? + new PojoMessageHandlerWholeBinary(listener, getOnMessageMethod(listener), session, + endpointConfig, + matchDecoders(target, endpointConfig, true, + ((WsSession) session).getInstanceManager()), + new Object[1], 0, true, -1, false, -1) : + new PojoMessageHandlerPartialBinary(listener, getOnMessagePartialMethod(listener), session, + new Object[2], 0, true, 1, -1, -1), + MessageHandlerResultType.BINARY); results.add(result); } else if (InputStream.class.isAssignableFrom(target)) { MessageHandlerResult result = new MessageHandlerResult( @@ -403,8 +406,8 @@ public class Util { } else { // Handler needs wrapping and requires decoder to convert it to one // of the types expected by the frame handling code - DecoderMatch decoderMatch = matchDecoders(target, endpointConfig, - ((WsSession) session).getInstanceManager()); + DecoderMatch decoderMatch = + matchDecoders(target, endpointConfig, ((WsSession) session).getInstanceManager()); Method m = getOnMessageMethod(listener); if (!decoderMatch.getBinaryDecoders().isEmpty()) { MessageHandlerResult result = new MessageHandlerResult( diff --git a/java/org/apache/tomcat/websocket/WsFrameClient.java b/java/org/apache/tomcat/websocket/WsFrameClient.java index 5911912e10..00c1351ab0 100644 --- a/java/org/apache/tomcat/websocket/WsFrameClient.java +++ b/java/org/apache/tomcat/websocket/WsFrameClient.java @@ -34,7 +34,7 @@ public class WsFrameClient extends WsFrameBase { private static final StringManager sm = StringManager.getManager(WsFrameClient.class); private final AsyncChannelWrapper channel; - private final CompletionHandler<Integer, Void> handler; + private final CompletionHandler<Integer,Void> handler; // Not final as it may need to be re-sized private volatile ByteBuffer response; @@ -143,7 +143,7 @@ public class WsFrameClient extends WsFrameBase { return log; } - private class WsFrameClientCompletionHandler implements CompletionHandler<Integer, Void> { + private class WsFrameClientCompletionHandler implements CompletionHandler<Integer,Void> { @Override public void completed(Integer result, Void attachment) { diff --git a/java/org/apache/tomcat/websocket/WsHandshakeResponse.java b/java/org/apache/tomcat/websocket/WsHandshakeResponse.java index a35f04dc54..e99c03f399 100644 --- a/java/org/apache/tomcat/websocket/WsHandshakeResponse.java +++ b/java/org/apache/tomcat/websocket/WsHandshakeResponse.java @@ -30,15 +30,15 @@ import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap; */ public class WsHandshakeResponse implements HandshakeResponse { - private final Map<String, List<String>> headers = new CaseInsensitiveKeyMap<>(); + private final Map<String,List<String>> headers = new CaseInsensitiveKeyMap<>(); public WsHandshakeResponse() { } - public WsHandshakeResponse(Map<String, List<String>> headers) { - for (Entry<String, List<String>> entry : headers.entrySet()) { + public WsHandshakeResponse(Map<String,List<String>> headers) { + for (Entry<String,List<String>> entry : headers.entrySet()) { if (this.headers.containsKey(entry.getKey())) { this.headers.get(entry.getKey()).addAll(entry.getValue()); } else { @@ -50,7 +50,7 @@ public class WsHandshakeResponse implements HandshakeResponse { @Override - public Map<String, List<String>> getHeaders() { + public Map<String,List<String>> getHeaders() { return headers; } } diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java index d235602a00..1dae971631 100644 --- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java +++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java @@ -208,8 +208,8 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { throw new IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullHandler")); } stateMachine.textStart(); - TextMessageSendHandler tmsh = new TextMessageSendHandler(handler, CharBuffer.wrap(text), true, encoder, - encoderBuffer, this); + TextMessageSendHandler tmsh = + new TextMessageSendHandler(handler, CharBuffer.wrap(text), true, encoder, encoderBuffer, this); tmsh.write(); // TextMessageSendHandler will update stateMachine when it completes } @@ -260,8 +260,8 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { void sendMessageBlock(byte opCode, ByteBuffer payload, boolean last, long timeout) throws IOException { /* - * Get the timeout before we send the message. The message may trigger a session close and depending on timing - * the client session may close before we can read the timeout. + * Get the timeout before we send the message. The message may trigger a session close and depending on timing + * the client session may close before we can read the timeout. */ sendMessageBlockInternal(opCode, payload, last, getTimeoutExpiry(timeout)); } @@ -512,9 +512,9 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { if (getBatchingAllowed() || isMasked()) { // Need to write via output buffer - OutputBufferSendHandler obsh = new OutputBufferSendHandler(mp.getEndHandler(), - mp.getBlockingWriteTimeoutExpiry(), headerBuffer, mp.getPayload(), mask, outputBuffer, - !getBatchingAllowed(), this); + OutputBufferSendHandler obsh = + new OutputBufferSendHandler(mp.getEndHandler(), mp.getBlockingWriteTimeoutExpiry(), headerBuffer, + mp.getPayload(), mask, outputBuffer, !getBatchingAllowed(), this); obsh.write(); } else { // Can write directly @@ -573,10 +573,9 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { /** * If a transformation needs to split a {@link MessagePart} into multiple {@link MessagePart}s, it uses this handler - * as the end handler for each of the additional {@link MessagePart}s. This handler notifies this class that - * the {@link MessagePart} has been processed and that the next {@link MessagePart} in the queue should be started. - * The final {@link MessagePart} will use the {@link EndMessageHandler} provided with the original - * {@link MessagePart}. + * as the end handler for each of the additional {@link MessagePart}s. This handler notifies this class that the + * {@link MessagePart} has been processed and that the next {@link MessagePart} in the queue should be started. The + * final {@link MessagePart} will use the {@link EndMessageHandler} provided with the original {@link MessagePart}. */ private static class IntermediateMessageHandler implements SendHandler { diff --git a/java/org/apache/tomcat/websocket/WsSession.java b/java/org/apache/tomcat/websocket/WsSession.java index a637399053..63d189229b 100644 --- a/java/org/apache/tomcat/websocket/WsSession.java +++ b/java/org/apache/tomcat/websocket/WsSession.java @@ -81,8 +81,8 @@ public class WsSession implements Session { // be sufficient to pass the validation tests. ServerEndpointConfig.Builder builder = ServerEndpointConfig.Builder.create(Object.class, "/"); ServerEndpointConfig sec = builder.build(); - SEC_CONFIGURATOR_USES_IMPL_DEFAULT = sec.getConfigurator().getClass() - .equals(DefaultServerEndpointConfigurator.class); + SEC_CONFIGURATOR_USES_IMPL_DEFAULT = + sec.getConfigurator().getClass().equals(DefaultServerEndpointConfigurator.class); } private final Endpoint localEndpoint; @@ -92,14 +92,14 @@ public class WsSession implements Session { private final ClassLoader applicationClassLoader; private final WsWebSocketContainer webSocketContainer; private final URI requestUri; - private final Map<String, List<String>> requestParameterMap; + private final Map<String,List<String>> requestParameterMap; private final String queryString; private final Principal userPrincipal; private final EndpointConfig endpointConfig; private final List<Extension> negotiatedExtensions; private final String subProtocol; - private final Map<String, String> pathParameters; + private final Map<String,String> pathParameters; private final boolean secure; private final String httpSessionId; private final String id; @@ -110,13 +110,13 @@ public class WsSession implements Session { private volatile MessageHandler binaryMessageHandler = null; private volatile MessageHandler.Whole<PongMessage> pongMessageHandler = null; private final AtomicReference<State> state = new AtomicReference<>(State.OPEN); - private final Map<String, Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); private volatile int maxBinaryMessageBufferSize = Constants.DEFAULT_BUFFER_SIZE; private volatile int maxTextMessageBufferSize = Constants.DEFAULT_BUFFER_SIZE; private volatile long maxIdleTimeout = 0; private volatile long lastActiveRead = System.currentTimeMillis(); private volatile long lastActiveWrite = System.currentTimeMillis(); - private final Map<FutureToSendHandler, FutureToSendHandler> futures = new ConcurrentHashMap<>(); + private final Map<FutureToSendHandler,FutureToSendHandler> futures = new ConcurrentHashMap<>(); private volatile Long sessionCloseTimeoutExpiry; @@ -139,7 +139,7 @@ public class WsSession implements Session { */ public WsSession(ClientEndpointHolder clientEndpointHolder, WsRemoteEndpointImplBase wsRemoteEndpoint, WsWebSocketContainer wsWebSocketContainer, List<Extension> negotiatedExtensions, String subProtocol, - Map<String, String> pathParameters, boolean secure, ClientEndpointConfig clientEndpointConfig) + Map<String,String> pathParameters, boolean secure, ClientEndpointConfig clientEndpointConfig) throws DeploymentException { this.wsRemoteEndpoint = wsRemoteEndpoint; this.wsRemoteEndpoint.setSession(this); @@ -201,9 +201,9 @@ public class WsSession implements Session { * @throws DeploymentException if an invalid encode is specified */ public WsSession(WsRemoteEndpointImplBase wsRemoteEndpoint, WsWebSocketContainer wsWebSocketContainer, - URI requestUri, Map<String, List<String>> requestParameterMap, String queryString, Principal userPrincipal, + URI requestUri, Map<String,List<String>> requestParameterMap, String queryString, Principal userPrincipal, String httpSessionId, List<Extension> negotiatedExtensions, String subProtocol, - Map<String, String> pathParameters, boolean secure, ServerEndpointConfig serverEndpointConfig) + Map<String,String> pathParameters, boolean secure, ServerEndpointConfig serverEndpointConfig) throws DeploymentException { this.wsRemoteEndpoint = wsRemoteEndpoint; @@ -269,8 +269,7 @@ public class WsSession implements Session { if (configurator.getClass().equals(DefaultServerEndpointConfigurator.class)) { return true; } - return SEC_CONFIGURATOR_USES_IMPL_DEFAULT && - configurator.getClass().equals(Configurator.class); + return SEC_CONFIGURATOR_USES_IMPL_DEFAULT && configurator.getClass().equals(Configurator.class); } @@ -633,9 +632,9 @@ public class WsSession implements Session { closeConnection(); } else if (state.compareAndSet(State.OUTPUT_CLOSING, State.CLOSING)) { /* - * The local endpoint sent a close message at the same time as the remote endpoint. The local close is - * still being processed. Update the state so the local close process will also close the network - * connection once it has finished sending a close message. + * The local endpoint sent a close message at the same time as the remote endpoint. The local close is still + * being processed. Update the state so the local close process will also close the network connection once + * it has finished sending a close message. */ } else if (state.compareAndSet(State.OUTPUT_CLOSED, State.CLOSED)) { /* @@ -908,7 +907,7 @@ public class WsSession implements Session { @Override - public Map<String, List<String>> getRequestParameterMap() { + public Map<String,List<String>> getRequestParameterMap() { checkState(); return requestParameterMap; } @@ -934,7 +933,7 @@ public class WsSession implements Session { @Override - public Map<String, String> getPathParameters() { + public Map<String,String> getPathParameters() { checkState(); return pathParameters; } @@ -947,7 +946,7 @@ public class WsSession implements Session { @Override - public Map<String, Object> getUserProperties() { + public Map<String,Object> getUserProperties() { checkState(); return userProperties; } diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java index cf4c5f7512..23058773b9 100644 --- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java +++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java @@ -93,8 +93,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce private final Log log = LogFactory.getLog(WsWebSocketContainer.class); // must not be static // Server side uses the endpoint path as the key // Client side uses the client endpoint instance - private final Map<Object, Set<WsSession>> endpointSessionMap = new HashMap<>(); - private final Map<WsSession, WsSession> sessions = new ConcurrentHashMap<>(); + private final Map<Object,Set<WsSession>> endpointSessionMap = new HashMap<>(); + private final Map<WsSession,WsSession> sessions = new ConcurrentHashMap<>(); private final Object endPointSessionMapLock = new Object(); private long defaultAsyncTimeout = -1; @@ -157,8 +157,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce if (configurator != null) { builder.configurator(configurator); } - return builder.decoders(Arrays.asList(annotation.decoders())) - .encoders(Arrays.asList(annotation.encoders())) + return builder.decoders(Arrays.asList(annotation.decoders())).encoders(Arrays.asList(annotation.encoders())) .preferredSubprotocols(Arrays.asList(annotation.subprotocols())).build(); } @@ -240,7 +239,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } } - Map<String, Object> userProperties = clientEndpointConfiguration.getUserProperties(); + Map<String,Object> userProperties = clientEndpointConfiguration.getUserProperties(); // If sa is null, no proxy is configured so need to create sa if (sa == null) { @@ -251,7 +250,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } // Create the initial HTTP request to open the WebSocket connection - Map<String, List<String>> reqHeaders = createRequestHeaders(host, port, secure, clientEndpointConfiguration); + Map<String,List<String>> reqHeaders = createRequestHeaders(host, port, secure, clientEndpointConfiguration); clientEndpointConfiguration.getConfigurator().beforeRequest(reqHeaders); if (Constants.DEFAULT_ORIGIN_HEADER_VALUE != null && !reqHeaders.containsKey(Constants.ORIGIN_HEADER_NAME)) { List<String> originValues = new ArrayList<>(1); @@ -342,8 +341,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce if (httpResponse.status != 101) { if (isRedirectStatus(httpResponse.status)) { - List<String> locationHeader = httpResponse.getHandshakeResponse().getHeaders() - .get(Constants.LOCATION_HEADER_NAME); + List<String> locationHeader = + httpResponse.getHandshakeResponse().getHeaders().get(Constants.LOCATION_HEADER_NAME); if (locationHeader == null || locationHeader.isEmpty() || locationHeader.get(0) == null || locationHeader.get(0).isEmpty()) { @@ -423,8 +422,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } success = true; - } catch (ExecutionException | InterruptedException | SSLException | EOFException | TimeoutException - | URISyntaxException | AuthenticationException e) { + } catch (ExecutionException | InterruptedException | SSLException | EOFException | TimeoutException | + URISyntaxException | AuthenticationException e) { throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } finally { if (!success) { @@ -470,7 +469,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce private Session processAuthenticationChallenge(ClientEndpointHolder clientEndpointHolder, ClientEndpointConfig clientEndpointConfiguration, URI path, Set<URI> redirectSet, - Map<String, Object> userProperties, ByteBuffer request, HttpResponse httpResponse, + Map<String,Object> userProperties, ByteBuffer request, HttpResponse httpResponse, AuthenticationType authenticationType) throws DeploymentException, AuthenticationException { if (userProperties.get(authenticationType.getAuthorizationHeaderName()) != null) { @@ -478,8 +477,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce Integer.valueOf(httpResponse.status), authenticationType.getAuthorizationHeaderName())); } - List<String> authenticateHeaders = httpResponse.getHandshakeResponse().getHeaders() - .get(authenticationType.getAuthenticateHeaderName()); + List<String> authenticateHeaders = + httpResponse.getHandshakeResponse().getHeaders().get(authenticationType.getAuthenticateHeaderName()); if (authenticateHeaders == null || authenticateHeaders.isEmpty() || authenticateHeaders.get(0) == null || authenticateHeaders.get(0).isEmpty()) { @@ -620,13 +619,13 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce return result; } - private static Map<String, List<String>> createRequestHeaders(String host, int port, boolean secure, + private static Map<String,List<String>> createRequestHeaders(String host, int port, boolean secure, ClientEndpointConfig clientEndpointConfiguration) { - Map<String, List<String>> headers = new HashMap<>(); + Map<String,List<String>> headers = new HashMap<>(); List<Extension> extensions = clientEndpointConfiguration.getExtensions(); List<String> subProtocols = clientEndpointConfiguration.getPreferredSubprotocols(); - Map<String, Object> userProperties = clientEndpointConfiguration.getUserProperties(); + Map<String,Object> userProperties = clientEndpointConfiguration.getUserProperties(); if (userProperties.get(Constants.AUTHORIZATION_HEADER_NAME) != null) { List<String> authValues = new ArrayList<>(1); @@ -718,7 +717,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } - private static ByteBuffer createRequest(URI uri, Map<String, List<String>> reqHeaders) { + private static ByteBuffer createRequest(URI uri, Map<String,List<String>> reqHeaders) { ByteBuffer result = ByteBuffer.allocate(4 * 1024); // Request line @@ -737,7 +736,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce result.put(HTTP_VERSION_BYTES); // Headers - for (Entry<String, List<String>> entry : reqHeaders.entrySet()) { + for (Entry<String,List<String>> entry : reqHeaders.entrySet()) { result = addHeader(result, entry.getKey(), entry.getValue()); } @@ -792,7 +791,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce private HttpResponse processResponse(ByteBuffer response, AsyncChannelWrapper channel, long timeout) throws InterruptedException, ExecutionException, DeploymentException, EOFException, TimeoutException { - Map<String, List<String>> headers = new CaseInsensitiveKeyMap<>(); + Map<String,List<String>> headers = new CaseInsensitiveKeyMap<>(); int status = 0; boolean readStatus = false; @@ -858,7 +857,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } - private void parseHeaders(String line, Map<String, List<String>> headers) { + private void parseHeaders(String line, Map<String,List<String>> headers) { // Treat headers as single values by default. int index = line.indexOf(':'); @@ -897,7 +896,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce private SSLEngine createSSLEngine(ClientEndpointConfig clientEndpointConfig, String host, int port) throws DeploymentException { - Map<String, Object> userProperties = clientEndpointConfig.getUserProperties(); + Map<String,Object> userProperties = clientEndpointConfig.getUserProperties(); try { // See if a custom SSLContext has been provided SSLContext sslContext = clientEndpointConfig.getSSLContext(); @@ -926,8 +925,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce KeyStoreUtil.load(ks, is, sslTrustStorePwdValue.toCharArray()); } - TrustManagerFactory tmf = TrustManagerFactory - .getInstance(TrustManagerFactory.getDefaultAlgorithm()); + TrustManagerFactory tmf = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); sslContext.init(null, tmf.getTrustManagers(), null); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org