[
https://issues.apache.org/jira/browse/WICKET-7162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18013464#comment-18013464
]
ASF GitHub Bot commented on WICKET-7162:
----------------------------------------
reiern70 commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2270314825
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketServerEndpointConfig.java:
##########
@@ -127,18 +128,33 @@ public void modifyHandshake(ServerEndpointConfig sec,
HandshakeRequest request,
// do not store null keys/values because Tomcat 8 uses
ConcurrentMap for UserProperties
Map<String, Object> userProperties =
sec.getUserProperties();
+
+ URI requestURI = request.getRequestURI();
+ LOG.trace("requestURI: {}", requestURI);
+ if (requestURI != null)
+ {
+ userProperties.put("requestURI", requestURI);
+ String path = requestURI.getPath();
+ if (path != null && path.indexOf("/wicket") >
0) {
+ String contextPath = path.substring(0,
path.indexOf("/wicket"));
+
userProperties.put(JavaxUpgradeHttpRequest.CONTEXT_PATH, contextPath);
+ }
+ }
+
Object httpSession = request.getHttpSession();
LOG.trace("httpSession: {}", httpSession);
- if (httpSession != null)
+ userProperties.put(JavaxUpgradeHttpRequest.SESSION,
httpSession);
+ if (httpSession instanceof HttpSession)
{
- userProperties.put("session", httpSession);
+
userProperties.put(JavaxUpgradeHttpRequest.CONTEXT_PATH,((HttpSession)httpSession).getServletContext().getContextPath());
Review Comment:
Adding this for "backwards compatibility"
> avoid NPE when web socket upgrade request is done in a stateless context
> ------------------------------------------------------------------------
>
> Key: WICKET-7162
> URL: https://issues.apache.org/jira/browse/WICKET-7162
> Project: Wicket
> Issue Type: Improvement
> Reporter: Ernesto Reinaldo Barreiro
> Assignee: Ernesto Reinaldo Barreiro
> Priority: Major
>
> JavaxUpgradeHttpRequest assumes there is a session. Thus, such a request will
> fail when there is none.
>
> {code:java}
> public JavaxUpgradeHttpRequest(final Session session, EndpointConfig
> endpointConfig)
> {
> Map<String, Object> userProperties = session.getUserProperties();
> if (userProperties == null || userProperties.isEmpty())
> {
> // workaround for JBoss Wildfly 8.0.Final
> userProperties = endpointConfig.getUserProperties();
> }
> this.httpSession = (HttpSession) userProperties.get("session");
> this.headers = (Map<String, List<String>>) userProperties.get("headers");
> this.queryString = session.getQueryString();
> this.userPrincipal = session.getUserPrincipal();
> Object requestURI = session.getRequestURI();
> this.requestUri = requestURI != null ? requestURI.toString() : "";
> this.contextPath = httpSession.getServletContext().getContextPath();
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)