ahgittin commented on a change in pull request #1157:
URL: https://github.com/apache/brooklyn-server/pull/1157#discussion_r604697677
##########
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 does allow that, but (personal preference) I find that
decreases readability and leads to bugs where the order of parameters gets out
of synch with the message, so I only do that where the savings in skipping the
string concatenation are likely to be significant when debug mode is off. (Or
alternatively do a `log.isDebugEnabled()` check.). This block should only
happen rarely during init so not worth it IMO.
--
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]