You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "reiern70 (via GitHub)" <gi...@apache.org> on 2025/08/11 17:36:37 UTC
[PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
reiern70 opened a new pull request, #1223:
URL: https://github.com/apache/wicket/pull/1223
…n a situation when there is no session (e.g. some stateless page).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2267529536
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java:
##########
@@ -75,14 +81,21 @@ public JavaxUpgradeHttpRequest(final Session session, EndpointConfig endpointCon
userProperties = endpointConfig.getUserProperties();
}
- this.httpSession = (HttpSession) userProperties.get("session");
- this.headers = (Map<String, List<String>>) userProperties.get("headers");
+ 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();
-
+ if (httpSession == null)
+ {
+ this.contextPath = "/";
Review Comment:
@martin-g I'm not sure this is correct or if this path is used anywhere else.. I was looking into code base and didn't see any other object from where we could take the path. We are getting this NPE from time to time on our test severs...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2270317462
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java:
##########
@@ -75,14 +82,13 @@ public JavaxUpgradeHttpRequest(final Session session, EndpointConfig endpointCon
userProperties = endpointConfig.getUserProperties();
}
- this.httpSession = (HttpSession) userProperties.get("session");
- this.headers = (Map<String, List<String>>) userProperties.get("headers");
+ 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();
-
+ this.contextPath = (String)userProperties.get(CONTEXT_PATH);
Review Comment:
Now this parameter should come either from session or from request URI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2270310408
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketServerEndpointConfig.java:
##########
@@ -131,14 +131,16 @@ public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
LOG.trace("httpSession: {}", httpSession);
if (httpSession != null)
{
- userProperties.put("session", httpSession);
+ userProperties.put(JavaxUpgradeHttpRequest.SESSION, httpSession);
+ } else {
+ sec.getPath();
Review Comment:
now it is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2270312785
##########
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();
Review Comment:
@martin-g I think this should always work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #1223:
URL: https://github.com/apache/wicket/pull/1223#discussion_r2267947463
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java:
##########
@@ -75,14 +81,21 @@ public JavaxUpgradeHttpRequest(final Session session, EndpointConfig endpointCon
userProperties = endpointConfig.getUserProperties();
}
- this.httpSession = (HttpSession) userProperties.get("session");
- this.headers = (Map<String, List<String>>) userProperties.get("headers");
+ 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();
-
+ if (httpSession == null)
+ {
+ this.contextPath = "/";
Review Comment:
I am not sure either. It should be OK.
##########
wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketServerEndpointConfig.java:
##########
@@ -131,14 +131,16 @@ public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
LOG.trace("httpSession: {}", httpSession);
if (httpSession != null)
{
- userProperties.put("session", httpSession);
+ userProperties.put(JavaxUpgradeHttpRequest.SESSION, httpSession);
+ } else {
+ sec.getPath();
Review Comment:
This seems unused
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
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"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WICKET-7162] avoid a NPE when a JavaxUpgradeHttpRequest is created i… [wicket]
Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 merged PR #1223:
URL: https://github.com/apache/wicket/pull/1223
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org