]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added a finalize() just in case a problem occurs during rendering and close() never...
authorAdrian Cumiskey <acumiskey@apache.org>
Tue, 22 Jul 2008 09:44:49 +0000 (09:44 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Tue, 22 Jul 2008 09:44:49 +0000 (09:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@678694 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/afp/DataObjectCache.java

index ee684db6f1960a7c5f4a7858b215139f065e0f63..85b96eff88c38410f0c844d18c9ba7c48fd56e97 100644 (file)
@@ -109,17 +109,33 @@ public final class DataObjectCache {
      */
     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
      *