From fbf0156a83cde22bfbfdacf2b6a59f19c169904f Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Wed, 10 Nov 2021 14:12:58 +0000 Subject: [PATCH 1/2] Fix #382 - clarify session idle timeout --- .../src/main/java/jakarta/websocket/Session.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/api/client/src/main/java/jakarta/websocket/Session.java b/api/client/src/main/java/jakarta/websocket/Session.java index 36ae8b0..a855007 100644 --- a/api/client/src/main/java/jakarta/websocket/Session.java +++ b/api/client/src/main/java/jakarta/websocket/Session.java @@ -170,17 +170,18 @@ public interface Session extends Closeable { boolean isOpen(); /** - * Return the number of milliseconds before this conversation may be closed by the container if it is inactive, i.e. - * no messages are either sent or received in that time. + * Return the number of milliseconds before this session will be closed by the container if it is inactive, i.e. no + * messages are either sent or received in that time. A value that is zero or negative indicates that this timeout + * will not be used. * * @return the timeout in milliseconds. */ long getMaxIdleTimeout(); /** - * Set the non-zero number of milliseconds before this session will be closed by the container if it is inactive, ie - * no messages are either sent or received. A value that is 0 or negative indicates the session will never timeout - * due to inactivity. + * Set the number of milliseconds before this session will be closed by the container if it is inactive, i.e. no + * messages are either sent or received in that time. A value that is zero or negative indicates that this timeout + * will not be used. * * @param milliseconds the number of milliseconds. */ From cc6ff45ac9f2a4e5fae3aa1ba34700b85c059d14 Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Wed, 10 Nov 2021 18:25:54 +0000 Subject: [PATCH 2/2] Further clarification of zero or negative timeout values --- .../java/jakarta/websocket/RemoteEndpoint.java | 6 +++--- .../java/jakarta/websocket/WebSocketContainer.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/client/src/main/java/jakarta/websocket/RemoteEndpoint.java b/api/client/src/main/java/jakarta/websocket/RemoteEndpoint.java index 6b71465..37ccbc6 100644 --- a/api/client/src/main/java/jakarta/websocket/RemoteEndpoint.java +++ b/api/client/src/main/java/jakarta/websocket/RemoteEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 Oracle and/or its affiliates and others. + * Copyright (c) 2018, 2021 Oracle and/or its affiliates and others. * All rights reserved. * * This program and the accompanying materials are made available under the @@ -132,7 +132,7 @@ interface Async extends RemoteEndpoint { /** * Return the number of milliseconds the implementation will timeout attempting to send a websocket message. A - * non-positive number indicates the implementation will not timeout attempting to send a websocket message + * zero or negative value indicates the implementation will not timeout attempting to send a websocket message * asynchronously. This value overrides the default value assigned in the WebSocketContainer. * * @return the timeout time in milliseconds. @@ -141,7 +141,7 @@ interface Async extends RemoteEndpoint { /** * Sets the number of milliseconds the implementation will timeout attempting to send a websocket message. A - * non-positive number indicates the implementation will not timeout attempting to send a websocket message + * zero or negative value indicates the implementation will not timeout attempting to send a websocket message * asynchronously. This value overrides the default value assigned in the WebSocketContainer. * * @param timeoutmillis The number of milliseconds this RemoteEndpoint will wait before timing out an incomplete diff --git a/api/client/src/main/java/jakarta/websocket/WebSocketContainer.java b/api/client/src/main/java/jakarta/websocket/WebSocketContainer.java index e221b50..04b8509 100644 --- a/api/client/src/main/java/jakarta/websocket/WebSocketContainer.java +++ b/api/client/src/main/java/jakarta/websocket/WebSocketContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019 Oracle and/or its affiliates and others. + * Copyright (c) 2018, 2021 Oracle and/or its affiliates and others. * All rights reserved. * * This program and the accompanying materials are made available under the @@ -38,7 +38,7 @@ public interface WebSocketContainer { /** * Return the number of milliseconds the implementation will timeout attempting to send a websocket message for all - * RemoteEndpoints associated with this container. A non-positive number indicates the implementation will not + * RemoteEndpoints associated with this container. A zero or negative value indicates the implementation will not * timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each * RemoteEndpoint. * @@ -48,11 +48,11 @@ public interface WebSocketContainer { /** * Sets the number of milliseconds the implementation will timeout attempting to send a websocket message for all - * RemoteEndpoints associated with this container. A non-positive number indicates the implementation will not + * RemoteEndpoints associated with this container. A zero or negative value indicates the implementation will not * timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each * RemoteEndpoint. * - * @param timeoutmillis the timeout in milliseconds or a non-positive number for no timeout + * @param timeoutmillis the timeout in milliseconds; use zero or negative value for no timeout */ void setAsyncSendTimeout(long timeoutmillis); @@ -130,7 +130,7 @@ Session connectToServer(Class endpointClass, ClientEndpointC /** * Return the default time in milliseconds after which any web socket sessions in this container will be closed if - * it has been inactive. A value that is 0 or negative indicates the sessions will never timeout due to inactivity. + * it has been inactive. A value that is zero or negative indicates the sessions will never timeout due to inactivity. * The value may be overridden on a per session basis using {@link Session#setMaxIdleTimeout(long) } * * @return the default number of milliseconds after which an idle session in this container will be closed @@ -139,10 +139,10 @@ Session connectToServer(Class endpointClass, ClientEndpointC /** * Sets the default time in milliseconds after which any web socket sessions in this container will be closed if it - * has been inactive. A value that is 0 or negative indicates the sessions will never timeout due to inactivity. The + * has been inactive. A value that is zero or negative indicates the sessions will never timeout due to inactivity. The * value may be overridden on a per session basis using {@link Session#setMaxIdleTimeout(long) } * - * @param timeout the maximum time in milliseconds. + * @param timeout the maximum time in milliseconds; use zero or negative value for no timeout */ void setDefaultMaxSessionIdleTimeout(long timeout);