You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/07/03 02:42:25 UTC
[jira] [Closed] (PDFBOX-408) Optional logger calls could be added
to COSDocument & PDJpeg when an error occurs.
[ https://issues.apache.org/jira/browse/PDFBOX-408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Hewson closed PDFBOX-408.
------------------------------
> Optional logger calls could be added to COSDocument & PDJpeg when an error occurs.
> -----------------------------------------------------------------------------------
>
> Key: PDFBOX-408
> URL: https://issues.apache.org/jira/browse/PDFBOX-408
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 0.8.0-incubator
> Environment: All
> Reporter: Peter_Lenahan@ibi.com
> Fix For: 2.0.0
>
>
> The return code of the delete was ignored.
> We really should log an error like this if it happened.
> COSBase extends LoggingObject
> org.apache.pdfbox.cos.COSDocument extends COSBase
> In COSDocument you could add calls to the logger to report any problems deleting a file.
> public void close() throws IOException
> {
> if( scratchFile != null )
> {
> scratchFile.close();
> scratchFile = null;
> }
> if( tmpFile != null )
> {
> boolean deleted=false;
> try {
> deleted=tmpFile.delete();
> if (!deleted)
> logger().severe("File was not deleted:"+tmpFile.getName());
> }
> catch (IOException e) {
> if (!deleted)
> logger().severe("File was not deleted IOException: "+tmpFile.getName());
> throw e;
> }
> catch (SecurityException se) {
> // If a security manager exists and its
> // java.lang.SecurityManager.checkDelete method denies delete
> // access to the file.
> if (!deleted)
> logger().severe("File was not deleted securityexception: "+tmpFile.getName());
> throw se;
> }
> tmpFile = null;
> }
> }
> package org.apache.pdfbox.pdmodel.graphics.xobject;
> public abstract class PDXObject implements COSObjectable
> public abstract class PDXObjectImage extends PDXObject
> public class PDJpeg extends PDXObjectImage
> To make logging available to PDJpeg you could extend the PDXObject class.
> public abstract class PDXObject extends LoggingObject implements COSObjectable
> Then in PDJpeg the logging of errors could be added for the delete method call, just like above.
> if (imgFile != null) {
> imgFile.delete();
> }
--
This message was sent by Atlassian JIRA
(v6.2#6252)