Java Code Examples for io.netty.channel.ChannelPipeline#fireExceptionCaught()
The following examples show how to use
io.netty.channel.ChannelPipeline#fireExceptionCaught() .
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: AbstractOioByteChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
Example 2
Source File: AbstractNioByteChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
Example 3
Source File: AbstractKQueueStreamChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, KQueueRecvByteAllocatorHandle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } if (!failConnectPromise(cause)) { allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { shutdownInput(false); } } }
Example 4
Source File: AbstractEpollStreamChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, EpollRecvByteAllocatorHandle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { shutdownInput(false); } }
Example 5
Source File: AbstractNioByteChannel.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close) { if (byteBuf != null) { if (byteBuf.isReadable()) { setReadPending(false); pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
Example 6
Source File: AbstractEpollStreamChannel.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
private boolean handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); return true; } return false; }
Example 7
Source File: AbstractXnioSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 6 votes |
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close) { if (byteBuf != null) { if (byteBuf.isReadable()) { pipeline.fireChannelRead(byteBuf); } else { try { byteBuf.release(); } catch (IllegalReferenceCountException ignore) { // ignore as it may be released already } } } pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(); } }
Example 8
Source File: AbstractOioMessageChannel.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
@Override protected void doRead() { if (!readPending) { // We have to check readPending here because the Runnable to read could have been scheduled and later // during the same read loop readPending was set to false. return; } // In OIO we should set readPending to false even if the read was not successful so we can schedule // another read on the event loop if no reads are done. readPending = false; final ChannelConfig config = config(); final ChannelPipeline pipeline = pipeline(); final RecvByteBufAllocator.Handle allocHandle = unsafe().recvBufAllocHandle(); allocHandle.reset(config); boolean closed = false; Throwable exception = null; try { do { // Perform a read. int localRead = doReadMessages(readBuf); if (localRead == 0) { break; } if (localRead < 0) { closed = true; break; } allocHandle.incMessagesRead(localRead); } while (allocHandle.continueReading()); } catch (Throwable t) { exception = t; } boolean readData = false; int size = readBuf.size(); if (size > 0) { readData = true; for (int i = 0; i < size; i++) { readPending = false; pipeline.fireChannelRead(readBuf.get(i)); } readBuf.clear(); allocHandle.readComplete(); pipeline.fireChannelReadComplete(); } if (exception != null) { if (exception instanceof IOException) { closed = true; } pipeline.fireExceptionCaught(exception); } if (closed) { if (isOpen()) { unsafe().close(unsafe().voidPromise()); } } else if (readPending || config.isAutoRead() || !readData && isActive()) { // Reading 0 bytes could mean there is a SocketTimeout and no data was actually read, so we // should execute read() again because no data may have been read. read(); } }
Example 9
Source File: KQueueDomainSocketChannel.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
private void readReadyFd() { if (socket.isInputShutdown()) { super.clearReadFilter0(); return; } final ChannelConfig config = config(); final KQueueRecvByteAllocatorHandle allocHandle = recvBufAllocHandle(); final ChannelPipeline pipeline = pipeline(); allocHandle.reset(config); readReadyBefore(); try { readLoop: do { // lastBytesRead represents the fd. We use lastBytesRead because it must be set so that the // KQueueRecvByteAllocatorHandle knows if it should try to read again or not when autoRead is // enabled. int recvFd = socket.recvFd(); switch(recvFd) { case 0: allocHandle.lastBytesRead(0); break readLoop; case -1: allocHandle.lastBytesRead(-1); close(voidPromise()); return; default: allocHandle.lastBytesRead(1); allocHandle.incMessagesRead(1); readPending = false; pipeline.fireChannelRead(new FileDescriptor(recvFd)); break; } } while (allocHandle.continueReading()); allocHandle.readComplete(); pipeline.fireChannelReadComplete(); } catch (Throwable t) { allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(t); } finally { readReadyFinally(config); } }
Example 10
Source File: EpollDomainSocketChannel.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
private void epollInReadFd() { if (socket.isInputShutdown()) { clearEpollIn0(); return; } final ChannelConfig config = config(); final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle(); allocHandle.edgeTriggered(isFlagSet(Native.EPOLLET)); final ChannelPipeline pipeline = pipeline(); allocHandle.reset(config); epollInBefore(); try { readLoop: do { // lastBytesRead represents the fd. We use lastBytesRead because it must be set so that the // EpollRecvByteAllocatorHandle knows if it should try to read again or not when autoRead is // enabled. allocHandle.lastBytesRead(socket.recvFd()); switch(allocHandle.lastBytesRead()) { case 0: break readLoop; case -1: close(voidPromise()); return; default: allocHandle.incMessagesRead(1); readPending = false; pipeline.fireChannelRead(new FileDescriptor(allocHandle.lastBytesRead())); break; } } while (allocHandle.continueReading()); allocHandle.readComplete(); pipeline.fireChannelReadComplete(); } catch (Throwable t) { allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(t); } finally { epollInFinally(config); } }