[jboss-cvs] JBossAS SVN: r92428 - in projects/vfs/branches/Branch_2_1/src: main/java/org/jboss/virtual/plugins/context/zip and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 17 10:39:45 EDT 2009


Author: jason.greene at jboss.com
Date: 2009-08-17 10:39:44 -0400 (Mon, 17 Aug 2009)
New Revision: 92428

Removed:
   projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/ZipReleaseAfterCopyTestCase.java
Modified:
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/DelegatingHandler.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipBytesWrapper.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryHandler.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipWrapper.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java
   projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
Log:
Revert everything after 88786.
The post-temp cleanup hack is unnecessary.


Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -46,7 +46,7 @@
 
 /**
  * AbstractVirtualFileHandler.
- *
+ * 
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @author Scott.Stark at jboss.org
@@ -74,7 +74,7 @@
     * @serialField rootURI URI the VFS context rootURI
     */
    private VFSContext context;
-
+   
    /**
     * The parent
     *
@@ -116,7 +116,7 @@
 
    /**
     * Create a new handler
-    *
+    * 
     * @param context the context
     * @param parent the parent
     * @param name the name
@@ -394,7 +394,7 @@
 
    /**
     * Initialise the path into the path name
-    *
+    * 
     * @param pathName the path name
     * @return whether it added anything
     */
@@ -536,7 +536,7 @@
 
    /**
     * Increment the reference count
-    *
+    * 
     * @return the resulting count
     */
    protected int increment()
@@ -546,7 +546,7 @@
 
    /**
     * Decrement the reference count
-    *
+    * 
     * @return the resulting count
     */
    protected int decrement()
@@ -556,10 +556,10 @@
 
    /**
     * Check whether we are closed
-    *
+    * 
     * @throws IllegalStateException when closed
     */
-   protected void checkClosed() throws IllegalStateException
+   protected void checkClosed() throws IllegalStateException 
    {
       if (references < 0)
          throw new IllegalStateException("Closed " + toStringLocal());
@@ -578,7 +578,7 @@
    public void cleanup()
    {
    }
-
+   
    /**
     * Is the handler temporary.
     *
@@ -612,14 +612,6 @@
    }
 
    /**
-    * Temporarily release file handles, if possible
-    */
-   public void releaseHandles()
-   {
-      // nothing
-   }
-
-   /**
     * Delete the file represented by this handler.
     *
     * File deletion is comprised of two parts:
@@ -704,7 +696,7 @@
 
    /**
     * Simple implementation of findChild
-    *
+    * 
     * @param path the path
     * @return the handler
     * @throws IOException for any error accessing the virtual file system
@@ -805,10 +797,10 @@
       close();
    }
    */
-
+   
    /**
     * Safely get a url version of the string
-    *
+    * 
     * @return the string or unknown if there is an error
     */
    private String safeToURLString()

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/DelegatingHandler.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/DelegatingHandler.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/DelegatingHandler.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -164,12 +164,6 @@
    }
 
    @Override
-   public void releaseHandles()
-   {
-      getDelegate().releaseHandles();
-   }
-
-   @Override
    public void close()
    {
       if (delegate == null)

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipBytesWrapper.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipBytesWrapper.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipBytesWrapper.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -130,11 +130,6 @@
       zipBytes = null;
    }
 
-   void releaseHandles()
-   {
-      // No file handles to release
-   }
-
    boolean delete(int gracePeriod) throws IOException
    {
       close();

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -872,7 +872,7 @@
    }
 
    /**
-    * Clean the handler's resources, if it's root.
+    * Close the handler, if it's root.
     *
     * @param handler the handler to close
     */
@@ -881,25 +881,11 @@
       VirtualFileHandler rootHandler = getRoot();
       if (rootHandler.equals(handler))
       {
-         getZipSource().close();
+         getZipSource().close(); // close == cleanup in zip source impl
       }
    }
 
    /**
-    * Temporarily release file handles if possible
-    *
-    * @param handler the handler to release
-    */
-   void releaseHandles(ZipEntryHandler handler)
-   {
-      VirtualFileHandler rootHandler = getRoot();
-      if (zipSource != null && rootHandler.equals(handler))
-      {
-         zipSource.releaseHandles();
-      }
-   }
-
-   /**
     * Returns lastModified timestamp for a given handler
     *
     * @param handler a handler

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryHandler.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryHandler.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryHandler.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -176,12 +176,6 @@
       getZipEntryContext().cleanup(this);
    }
 
-   @Override
-   public void releaseHandles()
-   {
-      getZipEntryContext().releaseHandles(this);
-   }
-
    public boolean delete(int gracePeriod) throws IOException
    {
       checkClosed();
@@ -268,7 +262,7 @@
          else
             return realUrl;
       }
-
+       
       throw new RuntimeException("Operation not supported for handler: " + this);
    }
 }

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -214,7 +214,7 @@
       InputStream is = zipFile.getInputStream(ent);
       if (is == null)
          throw new IOException("Entry no longer available: " + ent.getName() + " in file " + file);
-
+      
       ZipEntryInputStream zis = new ZipEntryInputStream(this, is);
 
       // debugging code
@@ -288,17 +288,6 @@
          file.delete();
    }
 
-   void releaseHandles()
-   {
-      try
-      {
-         closeZipFile();
-      }
-      catch(Exception ignored)
-      {
-      }
-   }
-
    void deleteFile(ZipFileWrapper wrapper) throws IOException
    {
       if (file.equals(wrapper.file))

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipWrapper.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipWrapper.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipWrapper.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -185,11 +185,6 @@
    abstract void close();
 
    /**
-    * Temporarily release handles if possible
-    */
-   abstract void releaseHandles();
-
-   /**
     * Delete this archive
     *
     * @param gracePeriod maximum time to wait for any locks

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -159,9 +159,6 @@
       if (parent != null && replaceOldHandler(parent, handler, newHandler))
          parent.replaceChild(handler, newHandler);
 
-      // Release underlying file, so that Windows won't lock it.
-      handler.releaseHandles();
-
       return newHandler.getVirtualFile();
    }
 
@@ -227,7 +224,7 @@
     */
    protected static void exactCopy(File copy, VirtualFileHandler root) throws IOException
    {
-      unpack(copy, root, COPY);
+      unpack(copy, root, COPY);   
    }
 
    /**
@@ -367,4 +364,4 @@
          }
       }
    }
-}
+}
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -34,7 +34,7 @@
 
 /**
  * A virtual file handler
- *
+ * 
  * @author Scott.Stark at jboss.org
  * @author Adrian.Brock
  * @author Ales.Justin at jboss.org
@@ -44,14 +44,14 @@
 {
    /**
     * Get the simple VF name (X.java)
-    *
+    * 
     * @return the simple file name
     */
    String getName();
 
    /**
     * Get the VFS relative path name (org/jboss/X.java)
-    *
+    * 
     * @return the VFS relative path name
     */
    String getPathName();
@@ -72,7 +72,7 @@
     * @throws MalformedURLException for any error
     */
    URL toVfsUrl() throws MalformedURLException, URISyntaxException;
-
+   
    /**
     * Get a file: or jar:file: URL representing a resource as precisely as possible.
     * file: urls can represent files in the file system  (i.e.: file:/classes/MyClass.class)
@@ -92,24 +92,24 @@
 
    /**
     * Get the VF URI (file://root/org/jboss/X.java)
-    *
+    * 
     * @return the full URI to the VF in the VFS.
-    * @throws URISyntaxException for an error parsing the URI
+    * @throws URISyntaxException for an error parsing the URI 
     */
    URI toURI() throws URISyntaxException;
 
    /**
     * Get the VF URL (file://root/org/jboss/X.java)
-    *
+    * 
     * @return the full URL to the VF in the VFS.
-    * @throws URISyntaxException for an error parsing the URI
+    * @throws URISyntaxException for an error parsing the URI 
     * @throws MalformedURLException for any error
     */
    URL toURL() throws MalformedURLException, URISyntaxException;
 
    /**
     * When the file was last modified
-    *
+    * 
     * @return the last modified time
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalStateException if closed
@@ -124,10 +124,10 @@
     * @throws IOException for any error
     */
    boolean hasBeenModified() throws IOException;
-
+   
    /**
     * Get the size
-    *
+    * 
     * @return the size
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalStateException if closed
@@ -144,13 +144,13 @@
    /**
     * Whether it is a simple leaf of the VFS,
     * i.e. whether it can contain other files
-    *
+    * 
     * @return true if a simple file.
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalStateException if the file is closed
     */
    boolean isLeaf() throws IOException;
-
+   
    /**
     * Does this represent an archive.
     * e.g. zip, tar, ...
@@ -162,7 +162,7 @@
 
    /**
     * Whether it is hidden
-    *
+    * 
     * @return true if hidden.
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalStateException if closed
@@ -171,7 +171,7 @@
 
    /**
     * Access the file contents.
-    *
+    * 
     * @return An InputStream for the file contents.
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalStateException if closed
@@ -180,7 +180,7 @@
 
    /**
     * Get the parent
-    *
+    * 
     * @return the parent
     * @throws IOException for an error accessing the file system
     * @throws IllegalStateException if closed
@@ -189,7 +189,7 @@
 
    /**
     * Get the children
-    *
+    * 
     * @param ignoreErrors whether to ignore errors
     * @return the children
     * @throws IOException for an error accessing the file system
@@ -219,7 +219,7 @@
 
    /**
     * Get the VFSContext this file belongs to
-    *
+    * 
     * @return the context
     * @throws IllegalStateException if closed
     */
@@ -227,7 +227,7 @@
 
    /**
     * Get the virtual file wrapper
-    *
+    * 
     * @return the wrapper
     * @throws IllegalStateException if closed
     */
@@ -244,11 +244,6 @@
    void close();
 
    /**
-    * Temporarily release file handles
-    */
-   void releaseHandles();
-
-   /**
     * Replace child.
     *
     * @param original the original

Modified: projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -102,7 +102,6 @@
       suite.addTest(TempCleanupUnitTestCase.suite());
       suite.addTest(ExplodeCleanupUnitTestCase.suite());
       suite.addTest(UnjarCleanupUnitTestCase.suite());
-      suite.addTest(ZipReleaseAfterCopyTestCase.suite());
 
       return suite;
    }

Deleted: projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/ZipReleaseAfterCopyTestCase.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/ZipReleaseAfterCopyTestCase.java	2009-08-17 14:31:14 UTC (rev 92427)
+++ projects/vfs/branches/Branch_2_1/src/test/java/org/jboss/test/virtual/test/ZipReleaseAfterCopyTestCase.java	2009-08-17 14:39:44 UTC (rev 92428)
@@ -1,189 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.virtual.test;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URL;
-
-import junit.framework.Test;
-
-import org.jboss.util.id.GUID;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.cache.LRUVFSCache;
-import org.jboss.virtual.plugins.context.DelegatingHandler;
-import org.jboss.virtual.plugins.context.zip.ZipEntryContext;
-import org.jboss.virtual.plugins.copy.AbstractCopyMechanism;
-import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.spi.cache.VFSCache;
-import org.jboss.virtual.spi.cache.VFSCacheFactory;
-import org.jboss.virtual.spi.registry.VFSRegistry;
-
-/**
- * Verify a zip file is released after a temp copy is made.
- *
- * @author Jason T. Greene
- */
-public class ZipReleaseAfterCopyTestCase extends AbstractVFSTest
-{
-   private File tempDir;
-
-   public ZipReleaseAfterCopyTestCase(String name)
-   {
-      super(name);
-   }
-
-   public static Test suite()
-   {
-      VFS.init();
-      return suite(ZipReleaseAfterCopyTestCase.class);
-   }
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      try
-      {
-         // nullify the temp dir
-         Class<?> clazz = AbstractCopyMechanism.class;
-         Field field = clazz.getDeclaredField("tempDir");
-         field.setAccessible(true);
-         field.set(null, null);
-
-         String tempDirKey = System.getProperty("vfs.temp.dir", "jboss.server.temp.dir");
-         String tempDirString = System.getProperty(tempDirKey, System.getProperty("java.io.tmpdir"));
-
-         tempDir = new File(new File(tempDirString), GUID.asString());
-         tempDir.deleteOnExit();
-         if (tempDir.exists())
-         {
-            deleteTempDir();
-         }
-         assertTrue("mkdir " + tempDir, tempDir.mkdir());
-
-         System.setProperty("jboss.server.temp.dir", tempDir.getCanonicalPath());
-
-         VFSCache cache = new LRUVFSCache(2, 5);
-         cache.start();
-         VFSCacheFactory.setInstance(cache);
-      }
-      catch (Exception e)
-      {
-         tearDown();
-         throw e;
-      }
-   }
-
-   protected String getProtocol()
-   {
-      return "vfszip:";
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      try
-      {
-         deleteTempDir();
-      }
-      catch (Throwable ignored)
-      {
-      }
-
-      try
-      {
-         VFSCacheFactory.getInstance().stop();
-         VFSCacheFactory.setInstance(null);
-
-         System.clearProperty("jboss.server.temp.dir");
-      }
-      catch (Throwable ignored)
-      {
-      }
-      finally
-      {
-         super.tearDown();
-      }
-   }
-
-   protected void deleteTempDir() throws IOException
-   {
-      // use vfs to disable possible reaper
-      VirtualFile td = VFS.getRoot(tempDir.toURI());
-      td.cleanup();
-      td.delete();
-   }
-
-
-   protected void assertNoRegistryEntry(URI uri) throws Exception
-   {
-      VFSRegistry registry = VFSRegistry.getInstance();
-      VirtualFile file = registry.getFile(uri);
-      assertNull("" + uri, file);
-   }
-
-   public void testReleaseAfterCopy() throws Exception
-   {
-      URL url = getResource("/vfs/test/nested/nested.jar");
-      VirtualFile root = VFS.getRoot(url);
-      assertNotNull(root);
-
-      VirtualFile copy = VFSUtils.explode(root); // ::temp doesn't create zipFile, explode does
-      try
-      {
-         assertNotNull(copy);
-         assertTrue(VFSUtils.isTemporaryFile(copy));
-
-         Method method = VirtualFile.class.getDeclaredMethod("getHandler");
-         method.setAccessible(true);
-         VirtualFileHandler h = (VirtualFileHandler)method.invoke(root);
-         if (h instanceof DelegatingHandler)
-            h = ((DelegatingHandler)h).getDelegate();
-
-         method = h.getClass().getDeclaredMethod("getZipEntryContext");
-         method.setAccessible(true);
-
-         Field field = ZipEntryContext.class.getDeclaredField("zipSource");
-         field.setAccessible(true);
-         Object object = field.get(method.invoke(h));
-
-         field = object.getClass().getDeclaredField("zipFile");
-         field.setAccessible(true);
-
-         assertNull(field.get(object));
-         assertNotNull(root.openStream());
-      }
-      finally
-      {
-         copy.cleanup();
-         root.cleanup();
-      }
-      assertNoRegistryEntry(root.toURI());
-   }
-}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list