import javax.xml.crypto.URIReferenceException;
import javax.xml.crypto.XMLCryptoContext;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
return baseUriDereferencer.dereference(uriReference, context);
}
- InputStream dataStream;
+ InputStream dataStream = null;
try {
dataStream = part.getInputStream();
}
}
} catch (IOException e) {
+ IOUtils.closeQuietly(dataStream);
throw new URIReferenceException("I/O error: " + e.getMessage(), e);
}
}
PackagePartName commentsName = PackagingURIHelper.createPartName(comments.getTargetURI());
PackagePart commentsPart = sheetPkg.getPackage().getPart(commentsName);
- return new XSSFBCommentsTable(commentsPart.getInputStream());
+ try (InputStream stream = commentsPart.getInputStream()) {
+ return new XSSFBCommentsTable(stream);
+ }
}
} catch (InvalidFormatException | IOException e) {
return null;