This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 46578dc3e7cc98ca907a2711ca48ecfc07042b9b Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Jun 20 10:19:10 2023 +0100 Update WebSocket API to align with latest proposals --- java/jakarta/websocket/SendResult.java | 50 ++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/java/jakarta/websocket/SendResult.java b/java/jakarta/websocket/SendResult.java index 47f5021aac..f506c881af 100644 --- a/java/jakarta/websocket/SendResult.java +++ b/java/jakarta/websocket/SendResult.java @@ -17,16 +17,53 @@ package jakarta.websocket; public final class SendResult { + private final Session session; private final Throwable exception; private final boolean ok; - public SendResult(Throwable exception) { + /** + * Create an instance for an unsuccessful message. + * + * @param session the WebSocket session in which the message was sent + * @param exception The exception describing the failure when trying to send the message. + */ + public SendResult(Session session, Throwable exception) { + this.session = session; this.exception = exception; this.ok = (exception == null); } + /** + * Create an instance for a successful message. + * + * @param session the WebSocket session in which the message was sent + */ + public SendResult(Session session) { + this(session, null); + } + + /** + * Create an instance for an unsuccessful message. + * + * @param exception The exception describing the failure when trying to send the message. + * + * @deprecated Deprecated in WebSocket 2.2 and will be removed in a future version. Use + * {@link #SendResult(Session, Throwable)} as a replacement. + */ + @Deprecated + public SendResult(Throwable exception) { + this(null, exception); + } + + /** + * Create an instance for a successful message. + * + * @deprecated Deprecated in WebSocket 2.2 and will be removed in a future version. Use + * {@link #SendResult(Session, Throwable)} as a replacement. + */ + @Deprecated public SendResult() { - this(null); + this(null, null); } public Throwable getException() { @@ -36,4 +73,13 @@ public final class SendResult { public boolean isOK() { return ok; } + + /** + * The WebSocket session in which the session was sent. + * + * @return the WebSocket session in which the session was sent or {@code null} if not known. + */ + public Session getSession() { + return session; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org