@@ -47,7 +47,7 @@ public class HazelcastHttpSession implements HttpSession {
4747 private final boolean stickySession ;
4848 private final boolean deferredWrite ;
4949 // true when session is fetched from local cache
50- private boolean keepRemoteActive = true ;
50+ private volatile boolean keepRemoteActive = true ;
5151 // only true if session is created first time in the cluster
5252 private volatile boolean clusterWideNew ;
5353 private final Set <String > transientAttributes ;
@@ -94,7 +94,7 @@ public void setAttribute(final String name, final Object value) {
9494 if (!deferredWrite && !transientEntry ) {
9595 try {
9696 webFilter .getClusteredSessionService ().setAttribute (id , name , value );
97- keepRemoteActive = false ;
97+ setKeepRemoteActive ( false ) ;
9898 entry .setDirty (false );
9999 } catch (HazelcastSerializationException e ) {
100100 LOGGER .warning ("Failed to serialize attribute [" + name + "]:" + e .getMessage (), e );
@@ -110,7 +110,7 @@ public Object getAttribute(final String name) {
110110 if (cacheEntry == null || cacheEntry .isReload ()) {
111111 try {
112112 value = webFilter .getClusteredSessionService ().getAttribute (id , name );
113- keepRemoteActive = false ;
113+ setKeepRemoteActive ( false ) ;
114114 cacheEntry = new LocalCacheEntry (transientAttributes .contains (name ), value );
115115 cacheEntry .setReload (false );
116116 localCache .put (name , cacheEntry );
@@ -194,7 +194,7 @@ public void removeAttribute(final String name) {
194194 if (!deferredWrite ) {
195195 try {
196196 webFilter .getClusteredSessionService ().deleteAttribute (id , name );
197- keepRemoteActive = false ;
197+ setKeepRemoteActive ( false ) ;
198198 if (entry != null ) {
199199 entry .setDirty (false );
200200 }
@@ -250,7 +250,7 @@ private void buildLocalCache() {
250250 Set <Map .Entry <String , Object >> entrySet = null ;
251251 try {
252252 entrySet = webFilter .getClusteredSessionService ().getAttributes (id );
253- keepRemoteActive = false ;
253+ setKeepRemoteActive ( false ) ;
254254 } catch (Exception e ) {
255255 return ;
256256 }
@@ -287,7 +287,7 @@ void sessionDeferredWrite() {
287287
288288 try {
289289 webFilter .getClusteredSessionService ().updateAttributes (id , updates );
290- keepRemoteActive = false ;
290+ setKeepRemoteActive ( false ) ;
291291 } catch (HazelcastSerializationException e ) {
292292 LOGGER .warning ("Failed to serialize session with ID [" + id + "]:" + e .getMessage (), e );
293293 } catch (Exception e ) {
@@ -302,7 +302,7 @@ private Set<String> selectKeys() {
302302 Set <String > attributeNames = null ;
303303 try {
304304 attributeNames = webFilter .getClusteredSessionService ().getAttributeNames (id );
305- keepRemoteActive = false ;
305+ setKeepRemoteActive ( false ) ;
306306 } catch (Exception ignored ) {
307307 for (Map .Entry <String , LocalCacheEntry > entry : localCache .entrySet ()) {
308308 if (!entry .getValue ().isRemoved () && entry .getValue ().getValue () != null ) {
@@ -354,7 +354,7 @@ public void updateReloadFlag() {
354354 public void keepRemoteActive () {
355355 try {
356356 webFilter .getClusteredSessionService ().getSessionAsync (id );
357- keepRemoteActive = false ;
357+ setKeepRemoteActive ( false ) ;
358358 } catch (Exception e ) {
359359 LOGGER .warning ("Failed to reset the idle-time on cluster for the session with ID [" + id + "]:"
360360 + e .getMessage (), e );
0 commit comments