THRIFT-661. java: Detect EOF in TIOStreamTransport

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Reiss 2010-03-09 05:19:14 +00:00
parent 487fd2e043
commit bec15e5105

View File

@ -122,11 +122,16 @@ public class TIOStreamTransport extends TTransport {
if (inputStream_ == null) {
throw new TTransportException(TTransportException.NOT_OPEN, "Cannot read from null inputStream");
}
int bytesRead;
try {
return inputStream_.read(buf, off, len);
bytesRead = inputStream_.read(buf, off, len);
} catch (IOException iox) {
throw new TTransportException(TTransportException.UNKNOWN, iox);
}
if (bytesRead < 0) {
throw new TTransportException(TTransportException.END_OF_FILE);
}
return bytesRead;
}
/**