diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-22 09:44:49 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-22 09:44:49 +0000 |
commit | 52b95f1c48e84eaaca934d8b0504734fd52fc9bf (patch) | |
tree | 193c54ee5a07483a39d0c730d677e0e7a35829a6 /src/java/org/apache/fop/render | |
parent | d91660dff59d9059d5f50173f9582e43c02f140e (diff) | |
download | xmlgraphics-fop-52b95f1c48e84eaaca934d8b0504734fd52fc9bf.tar.gz xmlgraphics-fop-52b95f1c48e84eaaca934d8b0504734fd52fc9bf.zip |
Added a finalize() just in case a problem occurs during rendering and close() never gets called.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@678694 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r-- | src/java/org/apache/fop/render/afp/DataObjectCache.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/render/afp/DataObjectCache.java b/src/java/org/apache/fop/render/afp/DataObjectCache.java index ee684db6f..85b96eff8 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectCache.java +++ b/src/java/org/apache/fop/render/afp/DataObjectCache.java @@ -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 * |