From 85aa3424b6e7abed6eb24c4d6f9a4108257fef53 Mon Sep 17 00:00:00 2001
From: Lachlan Roberts
* Binary messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
*/
- int maxBinaryMessageSize() default -2;
+ int maxBinaryMessageSize() default -1;
+
+ /**
+ * The time in ms (milliseconds) that a websocket may be idle before closing.
+ * @deprecated use {@link #idleTimeout()} instead
+ */
+ @Deprecated
+ int maxIdleTime() default -1;
/**
* The time in ms (milliseconds) that a websocket may be idle before closing.
*/
- int maxIdleTime() default -2;
+ int idleTimeout() default -1;
/**
* The maximum size of a text message during parsing/generating.
*
* Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
*/
- int maxTextMessageSize() default -2;
+ int maxTextMessageSize() default -1;
/**
* The output frame buffering mode.
diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java
index dd9b788ca146..a7f2f863c1a0 100644
--- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java
+++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java
@@ -296,14 +296,20 @@ private JettyWebSocketFrameHandlerMetadata createAnnotatedMetadata(WebSocket ann
{
JettyWebSocketFrameHandlerMetadata metadata = new JettyWebSocketFrameHandlerMetadata();
- if (anno.inputBufferSize()>=0)
- metadata.setInputBufferSize(anno.inputBufferSize());
- if (anno.maxBinaryMessageSize()>=0)
- metadata.setMaxBinaryMessageSize(anno.maxBinaryMessageSize());
- if (anno.maxTextMessageSize()>=0)
- metadata.setMaxTextMessageSize(anno.maxTextMessageSize());
- if (anno.maxIdleTime()>=0)
- metadata.setIdleTimeout(Duration.ofMillis(anno.maxIdleTime()));
+ int max = anno.inputBufferSize();
+ if (max>=0)
+ metadata.setInputBufferSize(max);
+ max = anno.maxBinaryMessageSize();
+ if (max>=0)
+ metadata.setMaxBinaryMessageSize(max);
+ max = anno.maxTextMessageSize();
+ if (max>=0)
+ metadata.setMaxTextMessageSize(max);
+ max = anno.idleTimeout();
+ if (max<0)
+ max = anno.maxIdleTime();
+ if (max>=0)
+ metadata.setIdleTimeout(Duration.ofMillis(max));
metadata.setBatchMode(anno.batchMode());
Method onmethod;
diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConfigTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConfigTest.java
index 3f352aefcae5..af87718d2402 100644
--- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConfigTest.java
+++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConfigTest.java
@@ -36,8 +36,8 @@
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.WebSocketSession;
-import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
import org.eclipse.jetty.websocket.core.internal.WebSocketConnection;
+import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletContainerInitializer;
import org.eclipse.jetty.websocket.tests.EchoSocket;
@@ -98,7 +98,7 @@ public void stop() throws Exception
server.stop();
}
- @WebSocket(maxIdleTime=idleTimeout, maxTextMessageSize=maxMessageSize, maxBinaryMessageSize=maxMessageSize, inputBufferSize=inputBufferSize, batchMode=BatchMode.ON)
+ @WebSocket(idleTimeout=idleTimeout, maxTextMessageSize=maxMessageSize, maxBinaryMessageSize=maxMessageSize, inputBufferSize=inputBufferSize, batchMode=BatchMode.ON)
public class AnnotatedConfigEndpoint extends EventSocket
{
}
@@ -182,7 +182,7 @@ public void testMaxBinaryMessageSize(String param) throws Exception
@ParameterizedTest
@MethodSource("data")
- public void testMaxIdleTime(String param) throws Exception
+ public void testIdleTimeout(String param) throws Exception
{
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/");
EventSocket clientEndpoint = getClientSocket(param);
diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerConfigTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerConfigTest.java
index 82c8681fd5ea..bcee42f5f8c0 100644
--- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerConfigTest.java
+++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerConfigTest.java
@@ -40,8 +40,8 @@
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.WebSocketSession;
-import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
import org.eclipse.jetty.websocket.core.internal.WebSocketConnection;
+import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer;
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletContainerInitializer;
@@ -96,7 +96,7 @@ public static Stream
- *
*
@@ -119,7 +119,13 @@ public void init() throws ServletException
components = WebSocketComponents.ensureWebSocketComponents(servletContext);
mapping = new WebSocketMapping(components);
- String max = getInitParameter("maxIdleTime");
+ String max = getInitParameter("idleTimeout");
+ if (max == null)
+ {
+ max = getInitParameter("maxIdleTime");
+ if (max != null)
+ LOG.warn("'maxIdleTime' init param is deprecated, use 'idleTimeout' instead");
+ }
if (max != null)
customizer.setIdleTimeout(Duration.ofMillis(Long.parseLong(max)));
diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java
index 6922bb3cc0b0..368a4b3b47d0 100644
--- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java
+++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java
@@ -55,7 +55,7 @@
* Configuration / Init-Parameters:
*