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
Showing
2 changed files
with
4 additions
and
0 deletions
| ... | @@ -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 | + if (notification.wasEvicted()) { | ||
| 315 | notification.getValue() | 316 | notification.getValue() |
| 316 | .setException(new ExecutionException("Timed out", | 317 | .setException(new ExecutionException("Timed out", |
| 317 | new TimeoutException())); | 318 | new TimeoutException())); |
| 318 | } | 319 | } |
| 319 | } | 320 | } |
| 321 | + } | ||
| 320 | } | 322 | } | ... | ... |
| ... | @@ -72,8 +72,10 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -72,8 +72,10 @@ 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 | + if (entry.wasEvicted()) { | ||
| 75 | entry.getValue().setException(new TimeoutException("Timedout waiting for reply")); | 76 | entry.getValue().setException(new TimeoutException("Timedout waiting for reply")); |
| 76 | } | 77 | } |
| 78 | + } | ||
| 77 | }) | 79 | }) |
| 78 | .build(); | 80 | .build(); |
| 79 | private final GenericKeyedObjectPool<Endpoint, Channel> channels | 81 | private final GenericKeyedObjectPool<Endpoint, Channel> channels | ... | ... |
-
Please register or login to post a comment