This is an automated email from the ASF dual-hosted git repository.

clesaec pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 5996cfe74 Revert "AVRO-3748 [java] fix SeekableInputStream.skip 
(#2203)" (#2446)
5996cfe74 is described below

commit 5996cfe74a68d2f4a9abcf2c1527070957af6779
Author: Christophe Le Saec <[email protected]>
AuthorDate: Wed Aug 16 11:43:35 2023 +0200

    Revert "AVRO-3748 [java] fix SeekableInputStream.skip (#2203)" (#2446)
    
    This reverts commit 33631e1e0fa48af0cd4ff46a32cbdb809e326177.
---
 .../java/org/apache/avro/file/DataFileReader.java  |  7 ++--
 .../apache/avro/file/TestSeekableInputStream.java  | 45 ----------------------
 2 files changed, 4 insertions(+), 48 deletions(-)

diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
index 7bf2c05b1..10067cd6c 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
@@ -312,11 +312,12 @@ public class DataFileReader<D> extends DataFileStream<D> 
implements FileReader<D
       long length = in.length();
       long remaining = length - position;
       if (remaining > skip) {
-        in.seek(position + skip);
+        in.seek(skip);
+        return in.tell() - position;
       } else {
-        in.seek(length);
+        in.seek(remaining);
+        return in.tell() - position;
       }
-      return in.tell() - position;
     }
 
     @Override
diff --git 
a/lang/java/avro/src/test/java/org/apache/avro/file/TestSeekableInputStream.java
 
b/lang/java/avro/src/test/java/org/apache/avro/file/TestSeekableInputStream.java
deleted file mode 100644
index 97715c044..000000000
--- 
a/lang/java/avro/src/test/java/org/apache/avro/file/TestSeekableInputStream.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.avro.file;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.file.Path;
-
-public class TestSeekableInputStream {
-    @Test
-    public void testSkip(@TempDir Path tempDir) throws IOException {
-        File f = tempDir.resolve("testSkip.avro").toFile();
-        try (FileWriter w = new FileWriter(f)) {
-            w.write("someContent");
-        }
-        try(SeekableFileInput in = new SeekableFileInput(f);
-            DataFileReader.SeekableInputStream stream = new 
DataFileReader.SeekableInputStream(in)
-        ) {
-            for (long i = 0; i < stream.length(); i++) {
-                Assertions.assertEquals(stream.length() - i, 
stream.available());
-                Assertions.assertEquals(1, stream.skip(1));
-            }
-        }
-    }
-}

Reply via email to