You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2013/08/08 22:15:22 UTC
svn commit: r1512016 - in /lucene/dev/branches/branch_4x/lucene: ./
CHANGES.txt core/ core/src/java/org/apache/lucene/store/NIOFSDirectory.java
core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
Author: gsingers
Date: Thu Aug 8 20:15:21 2013
New Revision: 1512016
URL: http://svn.apache.org/r1512016
Log:
LUCENE-5160: merge from trunk
Modified:
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1512016&r1=1512015&r2=1512016&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Thu Aug 8 20:15:21 2013
@@ -63,6 +63,10 @@ Bug Fixes
seek/lookup which can cause sideeffects if done on a cached FST root arc.
(Simon Willnauer)
+* LUCENE-5160: Handle the case where reading from a file or FileChannel returns -1, which
+ could happen in rare cases where something happens to the file between the time we start the
+ read loop (where we check the length) and when we actually do the read. (gsingers, yonik, Robert Muir, Uwe Schindler)
+
API Changes
* LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java?rev=1512016&r1=1512015&r2=1512016&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java Thu Aug 8 20:15:21 2013
@@ -174,6 +174,9 @@ public class NIOFSDirectory extends FSDi
}
bb.limit(limit);
int i = channel.read(bb, pos);
+ if (i < 0){//be defensive here, even though we checked before hand, something could have changed
+ throw new EOFException("read past EOF: " + this + " off: " + offset + " len: " + len + " pos: " + pos + " limit: " + limit + " end: " + end);
+ }
pos += i;
readOffset += i;
readLength -= i;
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java?rev=1512016&r1=1512015&r2=1512016&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java Thu Aug 8 20:15:21 2013
@@ -125,6 +125,9 @@ public class SimpleFSDirectory extends F
readLength = chunkSize;
}
final int i = file.read(b, offset + total, readLength);
+ if (i < 0){//be defensive here, even though we checked before hand, something could have changed
+ throw new EOFException("read past EOF: " + this + " off: " + offset + " len: " + len + " total: " + total + " readLen: " + readLength + " end: " + end);
+ }
total += i;
} while (total < len);
} catch (OutOfMemoryError e) {