Skip to content

Commit

Permalink
PDFBOX-5894: don't close prematurely, as suggested by Derek Wickern
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921703 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Oct 31, 2024
1 parent 635967d commit a56fb21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,19 @@ public static FDFDocument loadFDF(String filename) throws IOException
*/
public static FDFDocument loadFDF(File file) throws IOException
{
try (RandomAccessRead readBuffer = new RandomAccessReadBufferedFile(file))
RandomAccessRead raFile = null;
try
{
FDFParser parser = new FDFParser(readBuffer);
// PDFBOX-5894: RandomAccessRead is not closed here
raFile = new RandomAccessReadBufferedFile(file);
FDFParser parser = new FDFParser(raFile);
return parser.parse();
}
catch (IOException ioe)
{
IOUtils.closeQuietly(raFile);
throw ioe;
}
}

/**
Expand Down

0 comments on commit a56fb21

Please sign in to comment.