hadoop-ozone-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msi...@apache.org
Subject [hadoop-ozone] branch master updated: HDDS-2692. Seek to file end throws EOF Exception. (#326)
Date Sun, 08 Dec 2019 03:43:52 GMT
This is an automated email from the ASF dual-hosted git repository.

msingh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 1503ab8  HDDS-2692. Seek to file end throws EOF Exception. (#326)
1503ab8 is described below

commit 1503ab8beb40a628b5625147ecff50114e164664
Author: Ayush Saxena <ayushsaxena@apache.org>
AuthorDate: Sun Dec 8 09:13:43 2019 +0530

    HDDS-2692. Seek to file end throws EOF Exception. (#326)
---
 .../org/apache/hadoop/ozone/client/io/KeyInputStream.java    |  2 +-
 .../java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
index ea81f43..0ed61bf 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
@@ -207,7 +207,7 @@ public class KeyInputStream extends InputStream implements Seekable {
   @Override
   public synchronized void seek(long pos) throws IOException {
     checkOpen();
-    if (pos < 0 || pos >= length) {
+    if (pos < 0 || pos > length) {
       if (pos == 0) {
         // It is possible for length and pos to be zero in which case
         // seek should return instead of throwing exception
diff --git a/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java
b/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java
index 0dc7c99..370408b 100644
--- a/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java
@@ -23,6 +23,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -266,6 +267,17 @@ public class TestOzoneFileSystem {
   }
 
   @Test
+  public void testSeekOnFileLength() throws IOException {
+    Path file = new Path("/file");
+    ContractTestUtils.createFile(fs, file, true, "a".getBytes());
+    try (FSDataInputStream stream = fs.open(file)) {
+      long fileLength = fs.getFileStatus(file).getLen();
+      stream.seek(fileLength);
+      assertEquals(-1, stream.read());
+    }
+  }
+
+  @Test
   public void testNonExplicitlyCreatedPathExistsAfterItsLeafsWereRemoved()
       throws Exception {
     Path source = new Path("/source");


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org


Mime
View raw message