Fixed issue: NETTY-67 (ChannelBuffer.writeBytes() and setBytes() should not throw ClosedChannelException)
This commit is contained in:
parent
9aec8119cb
commit
630473bf84
@ -28,6 +28,7 @@ import java.io.OutputStream;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.nio.channels.GatheringByteChannel;
|
import java.nio.channels.GatheringByteChannel;
|
||||||
import java.nio.channels.ScatteringByteChannel;
|
import java.nio.channels.ScatteringByteChannel;
|
||||||
import java.nio.charset.UnsupportedCharsetException;
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
@ -253,7 +254,12 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
|||||||
int readBytes = 0;
|
int readBytes = 0;
|
||||||
|
|
||||||
while (readBytes < length) {
|
while (readBytes < length) {
|
||||||
int localReadBytes = in.read(slice);
|
int localReadBytes;
|
||||||
|
try {
|
||||||
|
localReadBytes = in.read(slice);
|
||||||
|
} catch (ClosedChannelException e) {
|
||||||
|
localReadBytes = -1;
|
||||||
|
}
|
||||||
if (localReadBytes < 0) {
|
if (localReadBytes < 0) {
|
||||||
if (readBytes == 0) {
|
if (readBytes == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -27,6 +27,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.nio.channels.GatheringByteChannel;
|
import java.nio.channels.GatheringByteChannel;
|
||||||
import java.nio.channels.ScatteringByteChannel;
|
import java.nio.channels.ScatteringByteChannel;
|
||||||
import java.nio.charset.UnsupportedCharsetException;
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
@ -157,7 +158,12 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
|||||||
int readBytes = 0;
|
int readBytes = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int localReadBytes = in.read(buf);
|
int localReadBytes;
|
||||||
|
try {
|
||||||
|
localReadBytes = in.read(buf);
|
||||||
|
} catch (ClosedChannelException e) {
|
||||||
|
localReadBytes = -1;
|
||||||
|
}
|
||||||
if (localReadBytes < 0) {
|
if (localReadBytes < 0) {
|
||||||
if (readBytes == 0) {
|
if (readBytes == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user