Java Code Examples for io.netty.util.concurrent.Future#cause()
The following examples show how to use
io.netty.util.concurrent.Future#cause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublishWritePromiseListener.java From hivemq-community-edition with Apache License 2.0 | 6 votes |
@Override public void operationComplete(final Future<? super Void> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (Exceptions.isConnectionClosedException(cause)) { log.trace("Failed to write publish. Client not connected anymore"); statusFuture.set(PublishStatus.NOT_CONNECTED); } else if (cause instanceof EncoderException) { Exceptions.rethrowError("Failed to write publish. Encoding Failure.", cause); final Throwable rootCause = cause.getCause(); if (cause != rootCause) { Exceptions.rethrowError("Failed to write publish. Encoding Failure, root cause:", rootCause); } statusFuture.set(PublishStatus.FAILED); } else { Exceptions.rethrowError("Failed to write publish.", cause); statusFuture.set(PublishStatus.FAILED); } } }
Example 2
Source File: SslBindClientHandler.java From arcusplatform with Apache License 2.0 | 6 votes |
private void onSslHandshakeComplete(Future<? super Channel> result, SslHandler handler) { try { if(!result.isSuccess()) { if (logger.isDebugEnabled()) { Throwable cause = result.cause(); if (!(cause instanceof ClosedChannelException)) { logger.debug("SSL handshake failed: {}", (cause == null) ? "unknown" : cause.getMessage(), cause); } } return; } String clientName = extractClientName(handler); if(clientName != null) { Channel channel = (Channel) result.get(); Client.bind(channel, registry.load(clientName)); } } catch(Exception e) { logger.debug("Unable to determine client auth", e); } }
Example 3
Source File: SearchDomainTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testExceptionMsgContainsSearchDomain() throws Exception { TestDnsServer.MapRecordStoreA store = new TestDnsServer.MapRecordStoreA(Collections.<String>emptySet()); dnsServer = new TestDnsServer(store); dnsServer.start(); resolver = newResolver().searchDomains(Collections.singletonList("foo.com")).ndots(1).build(); Future<InetAddress> fut = resolver.resolve("unknown.hostname"); assertTrue(fut.await(10, TimeUnit.SECONDS)); assertFalse(fut.isSuccess()); final Throwable cause = fut.cause(); assertThat(cause, instanceOf(UnknownHostException.class)); assertThat("search domain is included in UnknownHostException", cause.getMessage(), containsString("foo.com")); }
Example 4
Source File: SearchDomainTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testExceptionMsgDoesNotContainSearchDomainIfNdotsIsNotReached() throws Exception { TestDnsServer.MapRecordStoreA store = new TestDnsServer.MapRecordStoreA(Collections.<String>emptySet()); dnsServer = new TestDnsServer(store); dnsServer.start(); resolver = newResolver().searchDomains(Collections.singletonList("foo.com")).ndots(2).build(); Future<InetAddress> fut = resolver.resolve("unknown.hostname"); assertTrue(fut.await(10, TimeUnit.SECONDS)); assertFalse(fut.isSuccess()); final Throwable cause = fut.cause(); assertThat(cause, instanceOf(UnknownHostException.class)); assertThat("search domain is included in UnknownHostException", cause.getMessage(), not(containsString("foo.com"))); }
Example 5
Source File: FtdClientPool.java From ftdc with Apache License 2.0 | 6 votes |
/** * 释放连接 * @param channel * @return */ public Future<Void> release(Channel channel) { Verify.verifyNotNull(channel, "channel不允许为NULL"); InetSocketAddress remoteAddress = (InetSocketAddress)channel.remoteAddress(); if(logger.isDebugEnabled()) { logger.debug("{} channel released", remoteAddress); } FixedChannelPool fixedChannelPool = pollMap.get(remoteAddress); Future<Void> releaseFuture = fixedChannelPool.release(channel); if(!releaseFuture.isSuccess()) { Throwable cause = releaseFuture.cause(); if(cause != null) { logger.error("rlease local channel {}, remote channel {}, happens error {}", channel.localAddress(), channel.remoteAddress(), ExceptionUtils.getStackTrace(releaseFuture.cause())); } } return releaseFuture; }
Example 6
Source File: Http2MultiplexedChannelPool.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Override public void close() { if (closed.compareAndSet(false, true)) { Future<?> closeCompleteFuture = doClose(); try { if (!closeCompleteFuture.await(10, TimeUnit.SECONDS)) { throw new RuntimeException("Event loop didn't close after 10 seconds."); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } Throwable exception = closeCompleteFuture.cause(); if (exception != null) { throw new RuntimeException("Failed to close channel pool.", exception); } } }
Example 7
Source File: Http2MultiplexedChannelPool.java From ambry with Apache License 2.0 | 6 votes |
@Override public void close() { if (closed.compareAndSet(false, true)) { Future<?> closeCompleteFuture = doClose(); try { if (!closeCompleteFuture.await(10, TimeUnit.SECONDS)) { throw new RuntimeException("Event loop didn't close after 10 seconds."); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } Throwable exception = closeCompleteFuture.cause(); if (exception != null) { throw new RuntimeException("Failed to close channel pool.", exception); } } }
Example 8
Source File: ConnectionMultiListener.java From Bats with Apache License 2.0 | 5 votes |
@Override public void operationComplete(Future<Channel> future) throws Exception { if(parent != null){ if(future.isSuccess()) { Channel c = future.get(); parent.sslConnectionHandler.operationComplete(future); parent.parent.setSslChannel(c); } else { throw new DrillException("SSL handshake failed.", future.cause()); } } else { throw new RpcException("RPC Setup error. SSL handshake complete handler is not set up."); } }
Example 9
Source File: AbstractSniHandler.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
private void fireSniCompletionEvent(ChannelHandlerContext ctx, String hostname, Future<T> future) { Throwable cause = future.cause(); if (cause == null) { ctx.fireUserEventTriggered(new SniCompletionEvent(hostname)); } else { ctx.fireUserEventTriggered(new SniCompletionEvent(hostname, cause)); } }
Example 10
Source File: AbstractNettyServer.java From spring-boot-protocol with Apache License 2.0 | 5 votes |
protected void stopAfter(Future future){ //有异常抛出 Throwable cause = future.cause(); if(cause != null){ logger.error("stopAfter error={}",cause.toString(),cause); } logger.info("{} stop [port = {} , cause = {}]...",getName(),getPort(),cause); }
Example 11
Source File: RefreshingAddressResolverTest.java From armeria with Apache License 2.0 | 5 votes |
@Test void negativeTtl() { // TimeoutHandler times out only the first query. try (TestDnsServer server = new TestDnsServer(ImmutableMap.of(), new TimeoutHandler())) { final EventLoop eventLoop = eventLoopExtension.get(); final DnsResolverGroupBuilder builder = builder(server).negativeTtl(60).queryTimeoutMillis(1000); try (RefreshingAddressResolverGroup group = builder.build(eventLoop)) { final AddressResolver<InetSocketAddress> resolver = group.getResolver(eventLoop); final Future<InetSocketAddress> future = resolver.resolve( InetSocketAddress.createUnresolved("foo.com", 36462)); await().until(future::isDone); final Throwable cause = future.cause(); assertThat(cause).isInstanceOfAny(UnknownHostException.class, DnsTimeoutException.class); if (cause instanceof UnknownHostException) { assertThat(cause).hasCauseInstanceOf(DnsNameResolverTimeoutException.class); } // Because it's timed out, the result is not cached. final ConcurrentMap<String, CompletableFuture<CacheEntry>> cache = group.cache(); assertThat(cache.size()).isZero(); final Future<InetSocketAddress> future2 = resolver.resolve( InetSocketAddress.createUnresolved("foo.com", 36462)); await().until(future2::isDone); assertThat(future2.cause()).isInstanceOf(UnknownHostException.class) .hasNoCause(); // Because it is NXDOMAIN, the result is cached. assertThat(cache.size()).isOne(); } } }
Example 12
Source File: SimpleApnsClientCache.java From aerogear-unifiedpush-server with Apache License 2.0 | 5 votes |
@Override public void operationComplete(Future<? super Void> future) throws Exception { if (future.isSuccess()) { logger.debug("Successfully disconnected connection..."); } else { final Throwable t = future.cause(); logger.warn(t.getMessage(), t); } }