Skip to content

Commit

Permalink
Fixed issue #2187 - deferred write cached value isn't overridden on c…
Browse files Browse the repository at this point in the history
…hached NULL_ENTRY
  • Loading branch information
noctarius committed Apr 2, 2014
1 parent 2b3b9b5 commit 139e410
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hazelcast-wm/src/main/java/com/hazelcast/web/WebFilter.java
Expand Up @@ -519,7 +519,7 @@ public void putValue(final String name, final Object value) {
public void removeAttribute(final String name) {
if (deferredWrite) {
LocalCacheEntry entry = localCache.get(name);
if (entry != null) {
if (entry != null && entry != NULL_ENTRY) {
entry.value = null;
entry.removed = true;
// dirty needs to be set as last value for memory visibility reasons!
Expand All @@ -539,7 +539,7 @@ public void setAttribute(final String name, final Object value) {
}
if (deferredWrite) {
LocalCacheEntry entry = localCache.get(name);
if (entry == null) {
if (entry == null || entry == NULL_ENTRY) {
entry = new LocalCacheEntry();
localCache.put(name, entry);
}
Expand Down
Expand Up @@ -52,6 +52,23 @@ public WebfilterTestCase(String name, String serverXml1, String serverXml2) {
this.serverXml2 = serverXml2;
}

@Test(timeout = 60000)
public void test_github_issue_2187() throws Exception {
IMap<String, String> map = hz.getMap("default");

CookieStore cookieStore = new BasicCookieStore();
String value = executeRequest("read", serverPort1, cookieStore);
assertEquals("null", value);

executeRequest("write", serverPort1, cookieStore);

Set<Entry<String, String>> entrySet = map.entrySet();
assertEquals(2, entrySet.size());

value = executeRequest("read", serverPort1, cookieStore);
assertEquals("value", value);
}

@Test(timeout = 60000)
public void testAttributeDistribution() throws Exception {
IMap<String, Object> map = hz.getMap("default");
Expand Down

0 comments on commit 139e410

Please sign in to comment.