Fix NPE with EnableHazelcastHttpSession and add tests

This fixes the NPE caused by setting maxInactiveIntervalInSeconds = ""
on the EnableHazelcastHttpSession annotation. This is a basic scenario
that was not covered by integration tests. Tests configuring Hazelcast
with an XML file (probably the most common method in the wild) covering
the failing scenario and more have been added.
This commit is contained in:
Tommy Ludwig
2015-11-07 23:20:41 +09:00
committed by Rob Winch
parent 7186878f84
commit c701e1877e
5 changed files with 312 additions and 1 deletions

View File

@@ -89,7 +89,8 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur
/**
* Make a {@link MapConfig} for the given sessionMapName if one does not exist.
* Ensure that maxIdleSeconds is set to maxInactiveIntervalInSeconds for proper session expiration.
* Set Hazelcast's maxIdleSeconds to maxInactiveIntervalInSeconds if set (not "").
* Otherwise get the externally configured maxIdleSeconds for the distributed sessions map.
*
* @param hazelcastInstance the {@link HazelcastInstance} to configure
*/
@@ -97,6 +98,8 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur
MapConfig sessionMapConfig = hazelcastInstance.getConfig().getMapConfig(sessionMapName);
if (this.maxInactiveIntervalInSeconds != null) {
sessionMapConfig.setMaxIdleSeconds(this.maxInactiveIntervalInSeconds);
} else {
this.maxInactiveIntervalInSeconds = sessionMapConfig.getMaxIdleSeconds();
}
}