List of usage examples for io.netty.channel ChannelException ChannelException
public ChannelException(Throwable cause)
From source file:divconq.http.multipart.MemoryFileUpload.java
License:Apache License
@Override public FileUpload copy() { MemoryFileUpload upload = new MemoryFileUpload(getName(), getFilename(), getContentType(), getContentTransferEncoding(), getCharset(), size); ByteBuf buf = content();/*from www .j a v a 2s .c o m*/ if (buf != null) { try { upload.setContent(buf.copy()); return upload; } catch (IOException e) { throw new ChannelException(e); } } return upload; }
From source file:divconq.http.multipart.MemoryFileUpload.java
License:Apache License
@Override public FileUpload duplicate() { MemoryFileUpload upload = new MemoryFileUpload(getName(), getFilename(), getContentType(), getContentTransferEncoding(), getCharset(), size); ByteBuf buf = content();/*from w ww . j a va2s.c o m*/ if (buf != null) { try { upload.setContent(buf.duplicate()); return upload; } catch (IOException e) { throw new ChannelException(e); } } return upload; }
From source file:divconq.net.ssl.SslHandler.java
License:Apache License
@Override public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { if (!pendingUnencryptedWrites.isEmpty()) { // Check if queue is not empty first because create a new ChannelException is expensive pendingUnencryptedWrites// www. j av a 2 s . co m .removeAndFailAll(new ChannelException("Pending write on removal of SslHandler")); } }
From source file:io.grpc.alts.internal.TsiFrameHandler.java
License:Apache License
private void destroyProtectorAndWrites() { try {/* w w w . j a va 2 s . c o m*/ if (pendingUnprotectedWrites != null && !pendingUnprotectedWrites.isEmpty()) { pendingUnprotectedWrites .removeAndFailAll(new ChannelException("Pending write on teardown of TSI handler")); } } finally { pendingUnprotectedWrites = null; } if (protector != null) { try { protector.destroy(); } finally { protector = null; } } }
From source file:org.apache.pulsar.client.impl.ConnectionPool.java
License:Apache License
private CompletableFuture<ClientCnx> createConnection(InetSocketAddress address, int connectionKey) { if (log.isDebugEnabled()) { log.debug("Connection for {} not found in cache", address); }// w w w. j a v a2 s. c om final CompletableFuture<ClientCnx> cnxFuture = new CompletableFuture<ClientCnx>(); // Trigger async connect to broker bootstrap.connect(address).addListener((ChannelFuture future) -> { if (!future.isSuccess()) { log.warn("Failed to open connection to {} : {}", address, future.cause().getClass().getSimpleName()); cnxFuture.completeExceptionally(new PulsarClientException(future.cause())); cleanupConnection(address, connectionKey, cnxFuture); return; } log.info("[{}] Connected to server", future.channel()); future.channel().closeFuture().addListener(v -> { // Remove connection from pool when it gets closed if (log.isDebugEnabled()) { log.debug("Removing closed connection from pool: {}", v); } cleanupConnection(address, connectionKey, cnxFuture); }); // We are connected to broker, but need to wait until the connect/connected handshake is // complete final ClientCnx cnx = (ClientCnx) future.channel().pipeline().get("handler"); if (!future.channel().isActive() || cnx == null) { if (log.isDebugEnabled()) { log.debug("[{}] Connection was already closed by the time we got notified", future.channel()); } cnxFuture.completeExceptionally(new ChannelException("Connection already closed")); return; } cnx.connectionFuture().thenRun(() -> { if (log.isDebugEnabled()) { log.debug("[{}] Connection handshake completed", cnx.channel()); } cnxFuture.complete(cnx); }).exceptionally(exception -> { log.warn("[{}] Connection handshake failed: {}", cnx.channel(), exception.getMessage()); cnxFuture.completeExceptionally(exception); cleanupConnection(address, connectionKey, cnxFuture); cnx.ctx().close(); return null; }); }); return cnxFuture; }
From source file:org.msgpack.rpc.extension.socks.SocksProxyHandler.java
License:Open Source License
@Override protected void channelRead0(ChannelHandlerContext ctx, SocksResponse response) throws Exception { SocksResponseType rt = response.responseType(); switch (rt) { case INIT://from www. ja v a2 s . c om ctx.pipeline().addFirst("socks-cmd-decoder", new SocksCmdResponseDecoder()); InetSocketAddress addr = ((IPAddress) session.getAddress()).getInetSocketAddress(); SocksCmdRequest cmdSocks = new SocksCmdRequest(SocksCmdType.CONNECT, SocksAddressType.DOMAIN, addr.getHostName(), addr.getPort()); ctx.writeAndFlush(cmdSocks); break; case AUTH: break; case CMD: SocksCmdResponse scr = (SocksCmdResponse) response; ctx.pipeline().remove(this); ctx.pipeline().remove("socks-encode"); if (scr.cmdStatus() != SocksCmdStatus.SUCCESS) { throw new ChannelException("Socks faild."); } clientTransport.onSocksConnected(ctx.channel()); break; case UNKNOWN: default: throw new ChannelException("No support Socks Command."); } }