You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:03:50 UTC
[lucene] 13/18: 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
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 041cd9483ec082bc3848cd400c62d50092fc5016
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Fri Jan 22 18:39:32 2016 +0000
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
---
lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java | 6 +++++-
.../src/java/org/apache/lucene/store/BaseDirectoryTestCase.java | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
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);
+ }
+ }
}
}
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);