You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/07/22 11:44:50 UTC

svn commit: r678694 - /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java

Author: acumiskey
Date: Tue Jul 22 02:44:49 2008
New Revision: 678694

URL: http://svn.apache.org/viewvc?rev=678694&view=rev
Log:
Added a finalize() just in case a problem occurs during rendering and close() never gets called.

Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java?rev=678694&r1=678693&r2=678694&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java Tue Jul 22 02:44:49 2008
@@ -109,17 +109,33 @@
      */
     public void clear() {
         try {
-            raFile.close();
-            tempFile.delete();
+            if (raFile != null) {
+                raFile.close();
+                raFile = null;
+            }
+            if (tempFile != null) {
+                tempFile.delete();
+                tempFile = null;
+            }
         } catch (IOException e) {
-            log.error("Failed to close temporary file: " + e.getMessage());
+            log.error("Failed to close/delete temporary file: " + e.getMessage());
         } finally {
             synchronized (cacheMap) {
-                cacheMap.remove(id); // remove ourselves from the cache map
+                // remove ourselves from the cache map
+                cacheMap.remove(id); 
             }
         }
     }
 
+    /** {@inheritDoc} */
+    public void finalize() throws Throwable {
+        try {
+            clear();
+        } finally {
+            super.finalize();
+        }
+    }
+    
     /**
      * Stores a named data object in the cache
      * 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org