You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2025/11/15 20:26:28 UTC

svn commit: r1929778 - pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io

Author: tilman
Date: Sat Nov 15 20:26:28 2025
New Revision: 1929778

Log:
PDFBOX-5660: close input, as suggested by Valery Bokov; closes #339

Modified:
   pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferedFileTest.java

Modified: pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferedFileTest.java
==============================================================================
--- pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferedFileTest.java	Sat Nov 15 20:26:23 2025	(r1929777)
+++ pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferedFileTest.java	Sat Nov 15 20:26:28 2025	(r1929778)
@@ -27,6 +27,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 
 import org.junit.jupiter.api.Assertions;
@@ -254,13 +256,13 @@ class RandomAccessReadBufferedFileTest
     @Test
     void testReadFullyExact() throws IOException, URISyntaxException
     {
-        try (RandomAccessRead randomAccessSource = new RandomAccessReadBufferedFile(
-                new File(getClass().getResource("RandomAccessReadFile1.txt").toURI())))
+        Path path = Paths.get(getClass().getResource("RandomAccessReadFile1.txt").toURI());
+        try (RandomAccessRead randomAccessSource = new RandomAccessReadBufferedFile(path))
         {
             int length = (int) randomAccessSource.length();
             byte[] b = new byte[length];
             randomAccessSource.readFully(b);
-            byte[] allBytes = getClass().getResourceAsStream("RandomAccessReadFile1.txt").readAllBytes();
+            byte[] allBytes = Files.readAllBytes(path);
             Assertions.assertArrayEquals(allBytes, b);
         }
     }