lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwe...@apache.org
Subject lucene-solr:branch_7x: LUCENE-8568: TestMockDirectoryWrapper/ RAMInputStream NPE.
Date Tue, 20 Nov 2018 12:51:30 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x a4e95f39b -> 92f5bd8a3


LUCENE-8568: TestMockDirectoryWrapper/ RAMInputStream NPE.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/92f5bd8a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/92f5bd8a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/92f5bd8a

Branch: refs/heads/branch_7x
Commit: 92f5bd8a3d7e2dd95d7006a3d1c5c673924f7ab9
Parents: a4e95f3
Author: Dawid Weiss <dweiss@apache.org>
Authored: Tue Nov 20 13:37:29 2018 +0100
Committer: Dawid Weiss <dweiss@apache.org>
Committed: Tue Nov 20 13:51:25 2018 +0100

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/store/RAMInputStream.java | 11 +++++++++--
 .../org/apache/lucene/store/BaseDirectoryTestCase.java   |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/92f5bd8a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
index cb07b6e..312d638 100644
--- a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
+++ b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
@@ -72,17 +72,24 @@ public class RAMInputStream extends IndexInput implements Cloneable {
     if (bufferPosition == bufferLength) {
       nextBuffer();
     }
-    return currentBuffer[bufferPosition++];
+    if (currentBuffer == null) {
+      throw new EOFException();
+    } else {
+      return currentBuffer[bufferPosition++];
+    }
   }
 
   @Override
   public void readBytes(byte[] b, int offset, int len) throws IOException {
     while (len > 0) {
-
       if (bufferPosition == bufferLength) {
         nextBuffer();
       }
 
+      if (currentBuffer == null) {
+        throw new EOFException();
+      }
+
       int remainInBuffer = bufferLength - bufferPosition;
       int bytesToCopy = len < remainInBuffer ? len : remainInBuffer;
       System.arraycopy(currentBuffer, bufferPosition, b, offset, bytesToCopy);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/92f5bd8a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
index e49000b..d9eeb88 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
@@ -522,6 +522,9 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
 
       // But any read following the seek(len) should throw an EOFException.
       expectThrows(EOFException.class, i::readByte);
+      expectThrows(EOFException.class, () -> {
+        i.readBytes(new byte [1], 0, 1);
+      });
 
       i.close();
     }


Mime
View raw message