From 29e3acc88738e4b7700464fb26ad4e71e277200c Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Wed, 13 Sep 2023 08:53:19 +0100 Subject: [PATCH] Re-enable Jetty in spring-websocket tests --- .../web/socket/adapter/jetty/JettyWebSocketSession.java | 8 +++++++- .../web/socket/AbstractWebSocketIntegrationTests.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java index b3431bdd5630..ca67ba4e2f9f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java @@ -191,7 +191,13 @@ public void initializeNativeSession(Session session) { this.extensions = getExtensions(session); if (this.user == null) { - this.user = session.getUpgradeRequest().getUserPrincipal(); + try { + this.user = session.getUpgradeRequest().getUserPrincipal(); + } + catch (NullPointerException ex) { + // Necessary until https://github.com/eclipse/jetty.project/issues/10498 is resolved + logger.error("Failure from UpgradeRequest while getting Principal", ex); + } } } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java index e2b16cbba3fd..da72415b3090 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java @@ -62,6 +62,7 @@ public abstract class AbstractWebSocketIntegrationTests { static Stream argumentsFactory() { return Stream.of( + arguments(named("Jetty", new JettyWebSocketTestServer()), named("Standard", new StandardWebSocketClient())), arguments(named("Tomcat", new TomcatWebSocketTestServer()), named("Standard", new StandardWebSocketClient())), arguments(named("Undertow", new UndertowTestServer()), named("Standard", new StandardWebSocketClient()))); }