Skip to content

Commit d048354

Browse files
committed
PDFBOX-5660: close input, as suggested by Valery Bokov; closes #339
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929778 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6e6cb8c commit d048354

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferedFileTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import java.io.InputStream;
2828
import java.net.URISyntaxException;
2929
import java.nio.charset.StandardCharsets;
30+
import java.nio.file.Files;
31+
import java.nio.file.Path;
3032
import java.nio.file.Paths;
3133

3234
import org.junit.jupiter.api.Assertions;
@@ -254,13 +256,13 @@ void testReadFullyEOF() throws IOException, URISyntaxException
254256
@Test
255257
void testReadFullyExact() throws IOException, URISyntaxException
256258
{
257-
try (RandomAccessRead randomAccessSource = new RandomAccessReadBufferedFile(
258-
new File(getClass().getResource("RandomAccessReadFile1.txt").toURI())))
259+
Path path = Paths.get(getClass().getResource("RandomAccessReadFile1.txt").toURI());
260+
try (RandomAccessRead randomAccessSource = new RandomAccessReadBufferedFile(path))
259261
{
260262
int length = (int) randomAccessSource.length();
261263
byte[] b = new byte[length];
262264
randomAccessSource.readFully(b);
263-
byte[] allBytes = getClass().getResourceAsStream("RandomAccessReadFile1.txt").readAllBytes();
265+
byte[] allBytes = Files.readAllBytes(path);
264266
Assertions.assertArrayEquals(allBytes, b);
265267
}
266268
}

0 commit comments

Comments
 (0)