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 2019/08/21 19:13:03 UTC
svn commit: r1865653 -
/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
Author: tilman
Date: Wed Aug 21 19:13:02 2019
New Revision: 1865653
URL: http://svn.apache.org/viewvc?rev=1865653&view=rev
Log:
PDFBOX-4071: SonarQube fix: refactor nested try-catch, silence false positive
Modified:
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1865653&r1=1865652&r2=1865653&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Wed Aug 21 19:13:02 2019
@@ -977,21 +977,11 @@ public class PDDocument implements Close
public static PDDocument load(File file, String password, InputStream keyStore, String alias,
MemoryUsageSetting memUsageSetting) throws IOException
{
+ @SuppressWarnings({"squid:S2095"}) // raFile not closed here, may be needed for signing
RandomAccessBufferedFileInputStream raFile = new RandomAccessBufferedFileInputStream(file);
try
{
- ScratchFile scratchFile = new ScratchFile(memUsageSetting);
- try
- {
- PDFParser parser = new PDFParser(raFile, password, keyStore, alias, scratchFile);
- parser.parse();
- return parser.getPDDocument();
- }
- catch (IOException ioe)
- {
- IOUtils.closeQuietly(scratchFile);
- throw ioe;
- }
+ return load(raFile, password, keyStore, alias, memUsageSetting);
}
catch (IOException ioe)
{
@@ -999,6 +989,24 @@ public class PDDocument implements Close
throw ioe;
}
}
+
+ private static PDDocument load(RandomAccessBufferedFileInputStream raFile, String password,
+ InputStream keyStore, String alias,
+ MemoryUsageSetting memUsageSetting) throws IOException
+ {
+ ScratchFile scratchFile = new ScratchFile(memUsageSetting);
+ try
+ {
+ PDFParser parser = new PDFParser(raFile, password, keyStore, alias, scratchFile);
+ parser.parse();
+ return parser.getPDDocument();
+ }
+ catch (IOException ioe)
+ {
+ IOUtils.closeQuietly(scratchFile);
+ throw ioe;
+ }
+ }
/**
* Parses a PDF. The given input stream is copied to the memory to enable random access to the