SOLR-2861: retry if channel read returns 0 bytes

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1199013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-11-07 23:38:08 +00:00
parent 0d05013d86
commit 6ab4c631ca
1 changed files with 9 additions and 7 deletions

View File

@ -363,9 +363,6 @@ class TransactionLog {
Map<String,Integer> globalStringMap = new HashMap<String, Integer>();
List<String> globalStringList = new ArrayList<String>();
long lengthForDebugging;
// write a BytesRef as a byte array
JavaBinCodec.ObjectResolver resolver = new JavaBinCodec.ObjectResolver() {
@Override
@ -621,11 +618,16 @@ class ChannelFastInputStream extends FastInputStream {
ByteBuffer bb = ByteBuffer.wrap(target, offset, len);
assert chPosition < ch.size();
int ret = ch.read(bb, chPosition);
if (ret >= 0) {
chPosition += ret;
for (;;) {
int ret = ch.read(bb, chPosition);
if (ret > 0) {
chPosition += ret;
return ret;
} else if (ret < 0) {
return ret;
}
// a channel read can return 0 - retry if this happens
}
return ret;
}
@Override