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
@Override
public void onRemoval(RemovalNotification<Integer, SettableFuture<CompletedBatchOperation>> notification) {
// wrapping in ExecutionException to support Future.get
notification.getValue()
.setException(new ExecutionException("Timed out",
if (notification.wasEvicted()) {
notification.getValue()
.setException(new ExecutionException("Timed out",
new TimeoutException()));
}
}
}
}
......
......@@ -72,7 +72,9 @@ public class NettyMessagingService implements MessagingService {
.removalListener(new RemovalListener<Long, SettableFuture<byte[]>>() {
@Override
public void onRemoval(RemovalNotification<Long, SettableFuture<byte[]>> entry) {
entry.getValue().setException(new TimeoutException("Timedout waiting for reply"));
if (entry.wasEvicted()) {
entry.getValue().setException(new TimeoutException("Timedout waiting for reply"));
}
}
})
.build();
......