Commits

dr...@81dbac14-341a-0410-aa85-cbcd92e6f43e  committed 208b273

Submitter: Andres March

CACHE-112 Delete files when exception occurs during persistence

  • Participants
  • Parent commits 41be2d5
  • Branches v2_1_1

Comments (0)

Files changed (2)

 	<classpathentry kind="lib" path="lib/core/commons-collections-3.1.jar"/>
 	<classpathentry kind="lib" path="lib/build/ant-junit.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
 	<classpathentry kind="output" path="build"/>
 </classpath>

File src/plugins/diskpersistence/java/com/opensymphony/oscache/plugins/diskpersistence/AbstractDiskPersistenceListener.java

             oout.writeObject(obj);
             oout.flush();
         } catch (Exception e) {
+            while (file.exists() && !file.delete()) {
+                ;
+            }
+
             throw new CachePersistenceException("Unable to write '" + file + "' in the cache. Exception: " + e.getClass().getName() + ", Message: " + e.getMessage());
         } finally {
             try {