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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user