github-code-scanning[bot] commented on code in PR #2203:
URL: https://github.com/apache/avro/pull/2203#discussion_r1187149460
##########
lang/java/avro/src/test/java/org/apache/avro/file/TestSeekableInputStream.java:
##########
@@ -0,0 +1,28 @@
+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(DataFileReader.SeekableInputStream stream =
+ new DataFileReader.SeekableInputStream(new
SeekableFileInput(f))
+ ) {
+ for (int i = 0; i < stream.length(); i++) {
Review Comment:
## Comparison of narrow type with wide type in loop condition
Comparison between [expression](1) of type int and [expression](2) of wider
type long.
[Show more
details](https://github.com/apache/avro/security/code-scanning/2986)
##########
lang/java/avro/src/test/java/org/apache/avro/file/TestSeekableInputStream.java:
##########
@@ -0,0 +1,28 @@
+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(DataFileReader.SeekableInputStream stream =
+ new DataFileReader.SeekableInputStream(new
SeekableFileInput(f))
Review Comment:
## Potential input resource leak
This SeekableFileInput is not always closed on method exit.
[Show more
details](https://github.com/apache/avro/security/code-scanning/2985)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]