[jboss-cvs] JBossAS SVN: r84090 - in projects/vfs/trunk/src: test/java/org/jboss/test/virtual/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 11 07:23:35 EST 2009
Author: alesj
Date: 2009-02-11 07:23:35 -0500 (Wed, 11 Feb 2009)
New Revision: 84090
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java
Log:
Add cleaned check.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java 2009-02-11 11:52:52 UTC (rev 84089)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java 2009-02-11 12:23:35 UTC (rev 84090)
@@ -54,6 +54,9 @@
/** The virtual file handler */
private final VirtualFileHandler handler;
+ /** Whether we are cleaned */
+ private final AtomicBoolean cleaned = new AtomicBoolean(false);
+
/** Whether we are closed */
private final AtomicBoolean closed = new AtomicBoolean(false);
@@ -70,6 +73,7 @@
{
if (handler == null)
throw new IllegalArgumentException("Null handler");
+
this.handler = handler;
}
@@ -77,12 +81,27 @@
* Get the virtual file handler
*
* @return the handler
- * @throws IllegalStateException if the file is closed
+ * @throws IllegalStateException if the file is closed or cleaned
*/
VirtualFileHandler getHandler()
{
+ return getHandler(true);
+ }
+
+ /**
+ * Get the virtual handler.
+ *
+ * @param checkCleaned should we check cleaned
+ * @return the handler
+ * @throws IllegalStateException if the file is closed or cleaned
+ */
+ private VirtualFileHandler getHandler(boolean checkCleaned)
+ {
+ if (checkCleaned && cleaned.get())
+ throw new IllegalStateException("The virtual file is cleaned");
if (closed.get())
throw new IllegalStateException("The virtual file is closed");
+
return handler;
}
@@ -94,7 +113,7 @@
*/
public String getName()
{
- return getHandler().getName();
+ return getHandler(false).getName();
}
/**
@@ -105,7 +124,7 @@
*/
public String getPathName()
{
- return getHandler().getPathName();
+ return getHandler(false).getPathName();
}
/**
@@ -118,7 +137,7 @@
*/
public URL toURL() throws MalformedURLException, URISyntaxException
{
- return getHandler().toVfsUrl();
+ return getHandler(false).toVfsUrl();
}
/**
@@ -201,7 +220,7 @@
*/
public boolean isArchive() throws IOException
{
- return getHandler().isArchive();
+ return getHandler(false).isArchive();
}
/**
@@ -280,14 +299,24 @@
*/
public void cleanup()
{
- try
+ if (cleaned.get() == false)
{
- getHandler().cleanup();
+ try
+ {
+ try
+ {
+ getHandler().cleanup();
+ }
+ finally
+ {
+ VFS.cleanup(this);
+ }
+ }
+ finally
+ {
+ cleaned.set(true);
+ }
}
- finally
- {
- VFS.cleanup(this);
- }
}
/**
@@ -311,7 +340,7 @@
public boolean delete() throws IOException
{
// gracePeriod of 2 seconds
- return getHandler().delete(2000);
+ return getHandler(false).delete(2000);
}
/**
@@ -323,7 +352,7 @@
*/
public boolean delete(int gracePeriod) throws IOException
{
- return getHandler().delete(gracePeriod);
+ return getHandler(false).delete(gracePeriod);
}
/**
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java 2009-02-11 11:52:52 UTC (rev 84089)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java 2009-02-11 12:23:35 UTC (rev 84090)
@@ -111,7 +111,13 @@
try
{
deleteTempDir();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ try
+ {
VFSCacheFactory.getInstance().stop();
VFSCacheFactory.setInstance(null);
More information about the jboss-cvs-commits
mailing list