| 546 | // or the future hasn't completed yet (heh). |
| 547 | future.addListener(new ChannelFutureListener() { |
| 548 | public void operationComplete(final ChannelFuture future) { |
| 549 | if (future.isSuccess()) { |
| 550 | d.callback(null); |
| 551 | return; |
| 552 | } |
| 553 | final Throwable t = future.getCause(); |
| 554 | if (t instanceof Exception) { |
| 555 | d.callback(t); |
| 556 | } else { |
| 557 | // Wrap the Throwable because Deferred doesn't handle Throwables, |
| 558 | // it only uses Exception. |
| 559 | d.callback(new NonRecoverableException("Failed to shutdown: " |
| 560 | + RegionClient.this, t)); |
| 561 | } |
| 562 | } |
| 563 | }); |
| 564 | } |
| 565 | return d; |