Skip to content

Commit a12f1ca

Browse files
authored
[WICKET-7173] JavaxWebSocketConfigurator: Add back null check for httpSession (#1356)
Changes for WICKET-7162 removed a null check, leading to another NPE when trying to add httpSession to the userProperties map
1 parent 78857a3 commit a12f1ca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketServerEndpointConfig.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,15 @@ public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
143143

144144
Object httpSession = request.getHttpSession();
145145
LOG.trace("httpSession: {}", httpSession);
146-
userProperties.put(JavaxUpgradeHttpRequest.SESSION, httpSession);
147-
if (httpSession instanceof HttpSession)
146+
if (httpSession != null)
148147
{
149-
userProperties.put(JavaxUpgradeHttpRequest.CONTEXT_PATH,((HttpSession)httpSession).getServletContext().getContextPath());
148+
userProperties.put(JavaxUpgradeHttpRequest.SESSION, httpSession);
149+
if (httpSession instanceof HttpSession)
150+
{
151+
userProperties.put(JavaxUpgradeHttpRequest.CONTEXT_PATH,((HttpSession)httpSession).getServletContext().getContextPath());
152+
}
150153
}
151154

152-
153155
Map<String, List<String>> headers = request.getHeaders();
154156
LOG.trace("headers: {}", headers);
155157
if (headers != null)

0 commit comments

Comments
 (0)