Yuta HIGUCHI
Committed by Yuta Higuchi

Fix Cache Removal listener

- Removal lister will be called even if the entry was manually
  invalidated. Timeout handler should check for the cause.

Note: In both of the cases fixed in this patch, Future should silently ignore
  setException, external behavior-wise no change by this patch.

Change-Id: Id46f23c9ff8dfa607874cfd94807000f03a95b31
...@@ -312,9 +312,11 @@ public class SimpleFlowRuleStore ...@@ -312,9 +312,11 @@ public class SimpleFlowRuleStore
312 @Override 312 @Override
313 public void onRemoval(RemovalNotification<Integer, SettableFuture<CompletedBatchOperation>> notification) { 313 public void onRemoval(RemovalNotification<Integer, SettableFuture<CompletedBatchOperation>> notification) {
314 // wrapping in ExecutionException to support Future.get 314 // wrapping in ExecutionException to support Future.get
315 - notification.getValue() 315 + if (notification.wasEvicted()) {
316 - .setException(new ExecutionException("Timed out", 316 + notification.getValue()
317 + .setException(new ExecutionException("Timed out",
317 new TimeoutException())); 318 new TimeoutException()));
319 + }
318 } 320 }
319 } 321 }
320 } 322 }
......
...@@ -72,7 +72,9 @@ public class NettyMessagingService implements MessagingService { ...@@ -72,7 +72,9 @@ public class NettyMessagingService implements MessagingService {
72 .removalListener(new RemovalListener<Long, SettableFuture<byte[]>>() { 72 .removalListener(new RemovalListener<Long, SettableFuture<byte[]>>() {
73 @Override 73 @Override
74 public void onRemoval(RemovalNotification<Long, SettableFuture<byte[]>> entry) { 74 public void onRemoval(RemovalNotification<Long, SettableFuture<byte[]>> entry) {
75 - entry.getValue().setException(new TimeoutException("Timedout waiting for reply")); 75 + if (entry.wasEvicted()) {
76 + entry.getValue().setException(new TimeoutException("Timedout waiting for reply"));
77 + }
76 } 78 }
77 }) 79 })
78 .build(); 80 .build();
......