algairim commented on a change in pull request #1157:
URL: https://github.com/apache/brooklyn-server/pull/1157#discussion_r604669312
##########
File path:
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java
##########
@@ -638,12 +638,22 @@ public MultiSessionAttributeAdapter resetExpiration() {
Handler[] hh = getSessionHandlers();
if (hh!=null) {
for (Handler h: hh) {
- Session ss = ((SessionHandler)h).getSession(getId());
- if (ss!=null) {
+ Session ss = getSessionSafely(h, getId());
+ if (ss != null) {
ss.setMaxInactiveInterval(maxInativeInterval);
}
}
}
return this;
}
+
+ private static Session getSessionSafely(Handler h, String id) {
+ if (((SessionHandler)h).getSessionCache()==null) {
+ // suppress the log warning that the call to getSession can
trigger, if racing during startup
+ log.debug("Skipping session reset expiration for "+id+" on "+h+"
because session cache not initialized (yet)");
Review comment:
The logger should allow to parametrise the message like the following:
` log.debug("Skipping session reset expiration for {} on {}
because session cache not initialized (yet)", id, h);`
##########
File path:
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java
##########
@@ -638,12 +638,22 @@ public MultiSessionAttributeAdapter resetExpiration() {
Handler[] hh = getSessionHandlers();
if (hh!=null) {
for (Handler h: hh) {
- Session ss = ((SessionHandler)h).getSession(getId());
- if (ss!=null) {
+ Session ss = getSessionSafely(h, getId());
+ if (ss != null) {
ss.setMaxInactiveInterval(maxInativeInterval);
}
}
}
return this;
}
+
+ private static Session getSessionSafely(Handler h, String id) {
+ if (((SessionHandler)h).getSessionCache()==null) {
Review comment:
Check if Handler is an instance of SessionHandler first, log
debug/warning message "{h} is not a session handler" and return null.
##########
File path:
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java
##########
@@ -638,12 +638,22 @@ public MultiSessionAttributeAdapter resetExpiration() {
Handler[] hh = getSessionHandlers();
if (hh!=null) {
for (Handler h: hh) {
- Session ss = ((SessionHandler)h).getSession(getId());
- if (ss!=null) {
+ Session ss = getSessionSafely(h, getId());
+ if (ss != null) {
ss.setMaxInactiveInterval(maxInativeInterval);
}
}
}
return this;
}
+
+ private static Session getSessionSafely(Handler h, String id) {
Review comment:
Parameters are not expected to be modified, can be final.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]