diff --git a/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastRepositoryITests.java b/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastRepositoryITests.java index 1a8419be..9c4c03b7 100644 --- a/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastRepositoryITests.java +++ b/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastRepositoryITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,4 +153,18 @@ public abstract class AbstractHazelcastRepositoryITests { this.repository.deleteById(toSave.getId()); } + + @Test // gh-1076 + public void attemptToUpdateSessionAfterDelete() { + HazelcastSession session = this.repository.createSession(); + String sessionId = session.getId(); + this.repository.save(session); + session = this.repository.findById(sessionId); + session.setAttribute("attributeName", "attributeValue"); + this.repository.deleteById(sessionId); + this.repository.save(session); + + assertThat(this.repository.findById(sessionId)).isNull(); + } + } diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java index 195372c1..ac98fb84 100644 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java +++ b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -452,6 +452,9 @@ public class HazelcastSessionRepository implements @Override public Object process(Map.Entry entry) { MapSession value = entry.getValue(); + if (value == null) { + return Boolean.FALSE; + } value.setLastAccessedTime(this.lastAccessedTime); value.setMaxInactiveInterval(this.maxInactiveInterval); for (final Map.Entry attribute : this.delta.entrySet()) { @@ -463,7 +466,7 @@ public class HazelcastSessionRepository implements } } entry.setValue(value); - return value; + return Boolean.TRUE; } }