You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/02/10 17:27:32 UTC

[4/9] lucene-solr git commit: LUCENE-6932: fix test bug that was not always using the dir impl being tested; fix SimpleFSIndexInput to throw EOFException if you seek beyond end of file

LUCENE-6932: fix test bug that was not always using the dir impl being tested; fix SimpleFSIndexInput to throw EOFException if you seek beyond end of file

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1726277 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/branch_5_4
Commit: 041cd9483ec082bc3848cd400c62d50092fc5016
Parents: b4fa82b
Author: Michael McCandless <mi...@apache.org>
Authored: Fri Jan 22 18:39:32 2016 +0000
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Feb 10 10:47:03 2016 -0500

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/store/SimpleFSDirectory.java    | 6 +++++-
 .../java/org/apache/lucene/store/BaseDirectoryTestCase.java    | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/041cd948/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
index f30b383..2daf98f 100644
--- a/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
@@ -190,6 +190,10 @@ public class SimpleFSDirectory extends FSDirectory {
     }
 
     @Override
-    protected void seekInternal(long pos) throws IOException {}
+    protected void seekInternal(long pos) throws IOException {
+      if (pos > length()) {
+        throw new EOFException("read past EOF: pos=" + pos + " vs length=" + length() + ": " + this);
+      }
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/041cd948/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 af6b7b5..4748f37 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
@@ -1167,7 +1167,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   }
 
   public void testSeekToEndOfFile() throws IOException {
-    try (Directory dir = newDirectory()) {
+    try (Directory dir = getDirectory(createTempDir())) {
       try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
         for (int i = 0; i < 1024; ++i) {
           out.writeByte((byte) 0);
@@ -1183,7 +1183,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   }
 
   public void testSeekBeyondEndOfFile() throws IOException {
-    try (Directory dir = newDirectory()) {
+    try (Directory dir = getDirectory(createTempDir())) {
       try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
         for (int i = 0; i < 1024; ++i) {
           out.writeByte((byte) 0);