You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2004/12/21 22:54:33 UTC

cvs commit: jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test ProviderWriteTests.java

imario      2004/12/21 13:54:33

  Modified:    vfs/src/java/org/apache/commons/vfs/provider
                        AbstractFileObject.java DefaultFileContent.java
               vfs/src/java/org/apache/commons/vfs/impl
                        DefaultFileSystemManager.java
               vfs/src/test/org/apache/commons/vfs/provider/zip/test
                        NestedZipTestCase.java ZipProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/test
                        ProviderWriteTests.java
  Added:       vfs/src/java/org/apache/commons/vfs/provider
                        FileContentThreadData.java
  Log:
  again a step to thread-safety.
  Now it should be possible to use VFS's singleton pattern safely in an multithreaded environment.
  Though VFS do not deal with locking or transaction. This is something a LockManager or TransactionManager has todo.
  
  Revision  Changes    Path
  1.52      +176 -159  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
  
  Index: AbstractFileObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- AbstractFileObject.java	11 Oct 2004 19:27:53 -0000	1.51
  +++ AbstractFileObject.java	21 Dec 2004 21:54:32 -0000	1.52
  @@ -55,14 +55,14 @@
    * @todo Check caps in methods like getChildren(), etc, and give better error messages
    * (eg 'this file type does not support listing children', vs 'this is not a folder')
    */
  -public abstract class AbstractFileObject
  -    implements FileObject
  +public abstract class AbstractFileObject implements FileObject
   {
       // private static final FileObject[] EMPTY_FILE_ARRAY = {};
       private static final FileName[] EMPTY_FILE_ARRAY = {};
   
       private final FileName name;
       private final AbstractFileSystem fs;
  +
       private DefaultFileContent content;
   
       // Cached info
  @@ -75,6 +75,7 @@
       // private FileObject[] children;
       private FileName[] children;
   
  +
       protected AbstractFileObject(final FileName name,
                                    final AbstractFileSystem fs)
       {
  @@ -494,10 +495,13 @@
               }
           }
   
  -        // Locate the parent of this file
  -        if (parent == null)
  +        synchronized (this)
           {
  -            parent = (AbstractFileObject) fs.resolveFile(name.getParent());
  +            // Locate the parent of this file
  +            if (parent == null)
  +            {
  +                parent = (AbstractFileObject) fs.resolveFile(name.getParent());
  +            }
           }
           return parent;
       }
  @@ -507,65 +511,68 @@
        */
       public FileObject[] getChildren() throws FileSystemException
       {
  -        attach();
  -        if (!type.hasChildren())
  +        synchronized (this)
           {
  -            throw new FileSystemException("vfs.provider/list-children-not-folder.error", name);
  -        }
  +            attach();
  +            if (!type.hasChildren())
  +            {
  +                throw new FileSystemException("vfs.provider/list-children-not-folder.error", name);
  +            }
   
  -        // Use cached info, if present
  -        if (children != null)
  -        {
  -            return resolveFiles(children);
  -        }
  +            // Use cached info, if present
  +            if (children != null)
  +            {
  +                return resolveFiles(children);
  +            }
   
  -        // allow the filesystem to return resolved children. e.g. prefill type for webdav
  -        FileObject[] childrenObjects;
  -        try
  -        {
  -            childrenObjects = doListChildrenResolved();
  -            children = extractNames(childrenObjects);
  -        }
  -        catch (Exception exc)
  -        {
  -            throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
  -        }
  +            // allow the filesystem to return resolved children. e.g. prefill type for webdav
  +            FileObject[] childrenObjects;
  +            try
  +            {
  +                childrenObjects = doListChildrenResolved();
  +                children = extractNames(childrenObjects);
  +            }
  +            catch (Exception exc)
  +            {
  +                throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
  +            }
   
  -        if (childrenObjects != null)
  -        {
  -            return childrenObjects;
  -        }
  +            if (childrenObjects != null)
  +            {
  +                return childrenObjects;
  +            }
   
  -        // List the children
  -        final String[] files;
  -        try
  -        {
  -            files = doListChildren();
  -        }
  -        catch (Exception exc)
  -        {
  -            throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
  -        }
  +            // List the children
  +            final String[] files;
  +            try
  +            {
  +                files = doListChildren();
  +            }
  +            catch (Exception exc)
  +            {
  +                throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
  +            }
   
  -        if (files == null || files.length == 0)
  -        {
  -            // No children
  -            children = EMPTY_FILE_ARRAY;
  -        }
  -        else
  -        {
  -            // Create file objects for the children
  -            // children = new FileObject[files.length];
  -            children = new FileName[files.length];
  -            for (int i = 0; i < files.length; i++)
  +            if (files == null || files.length == 0)
               {
  -                final String file = files[i];
  -                // children[i] = fs.resolveFile(name.resolveName(file, NameScope.CHILD));
  -                children[i] = name.resolveName(file, NameScope.CHILD);
  +                // No children
  +                children = EMPTY_FILE_ARRAY;
  +            }
  +            else
  +            {
  +                // Create file objects for the children
  +                // children = new FileObject[files.length];
  +                children = new FileName[files.length];
  +                for (int i = 0; i < files.length; i++)
  +                {
  +                    final String file = files[i];
  +                    // children[i] = fs.resolveFile(name.resolveName(file, NameScope.CHILD));
  +                    children[i] = name.resolveName(file, NameScope.CHILD);
  +                }
               }
  -        }
   
  -        return resolveFiles(children);
  +            return resolveFiles(children);
  +        }
       }
   
       private FileName[] extractNames(FileObject[] objects)
  @@ -611,11 +618,11 @@
       public FileObject getChild(final String name) throws FileSystemException
       {
           // TODO - use a hashtable when there are a large number of children
  -        getChildren();
  +        FileObject[] children = getChildren();
           for (int i = 0; i < children.length; i++)
           {
               // final FileObject child = children[i];
  -            final FileName child = children[i];
  +            final FileName child = children[i].getName();
               // TODO - use a comparator to compare names
               // if (child.getName().getBaseName().equals(name))
               if (child.getBaseName().equals(name))
  @@ -632,7 +639,6 @@
       public FileObject resolveFile(final String name, final NameScope scope)
           throws FileSystemException
       {
  -        // TODO - cache children (only if they exist)
           return fs.resolveFile(this.name.resolveName(name, scope));
       }
   
  @@ -657,35 +663,38 @@
        */
       private boolean deleteSelf() throws FileSystemException
       {
  -        if (!isWriteable())
  +        synchronized (this)
           {
  -            throw new FileSystemException("vfs.provider/delete-read-only.error", name);
  -        }
  +            if (!isWriteable())
  +            {
  +                throw new FileSystemException("vfs.provider/delete-read-only.error", name);
  +            }
   
  -        if (type == FileType.IMAGINARY)
  -        {
  -            // File does not exist
  -            return false;
  -        }
  +            if (getType() == FileType.IMAGINARY)
  +            {
  +                // File does not exist
  +                return false;
  +            }
   
  -        try
  -        {
  -            // Delete the file
  -            doDelete();
  +            try
  +            {
  +                // Delete the file
  +                doDelete();
   
  -            // Update cached info
  -            handleDelete();
  -        }
  -        catch (final RuntimeException re)
  -        {
  -            throw re;
  -        }
  -        catch (final Exception exc)
  -        {
  -            throw new FileSystemException("vfs.provider/delete.error", new Object[]{name}, exc);
  -        }
  +                // Update cached info
  +                handleDelete();
  +            }
  +            catch (final RuntimeException re)
  +            {
  +                throw re;
  +            }
  +            catch (final Exception exc)
  +            {
  +                throw new FileSystemException("vfs.provider/delete.error", new Object[]{name}, exc);
  +            }
   
  -        return true;
  +            return true;
  +        }
       }
   
       /**
  @@ -706,11 +715,9 @@
        */
       public int delete(final FileSelector selector) throws FileSystemException
       {
  -        attach();
  -
           int nuofDeleted = 0;
   
  -        if (type == FileType.IMAGINARY)
  +        if (getType() == FileType.IMAGINARY)
           {
               // File does not exist
               return nuofDeleted;
  @@ -725,10 +732,10 @@
           for (int i = 0; i < count; i++)
           {
               final AbstractFileObject file = (AbstractFileObject) files.get(i);
  -            file.attach();
  +            // file.attach();
   
               // If the file is a folder, make sure all its children have been deleted
  -            if (file.type == FileType.FOLDER && file.getChildren().length != 0)
  +            if (file.getType() == FileType.FOLDER && file.getChildren().length != 0)
               {
                   // Skip - as the selector forced us not to delete all files
                   continue;
  @@ -750,18 +757,21 @@
        */
       public void createFile() throws FileSystemException
       {
  -        try
  -        {
  -            getOutputStream().close();
  -            endOutput();
  -        }
  -        catch (final RuntimeException re)
  -        {
  -            throw re;
  -        }
  -        catch (final Exception e)
  +        synchronized (this)
           {
  -            throw new FileSystemException("vfs.provider/create-file.error", name, e);
  +            try
  +            {
  +                getOutputStream().close();
  +                endOutput();
  +            }
  +            catch (final RuntimeException re)
  +            {
  +                throw re;
  +            }
  +            catch (final Exception e)
  +            {
  +                throw new FileSystemException("vfs.provider/create-file.error", name, e);
  +            }
           }
       }
   
  @@ -771,43 +781,45 @@
        */
       public void createFolder() throws FileSystemException
       {
  -        attach();
  -        if (type == FileType.FOLDER)
  -        {
  -            // Already exists as correct type
  -            return;
  -        }
  -        if (type != FileType.IMAGINARY)
  -        {
  -            throw new FileSystemException("vfs.provider/create-folder-mismatched-type.error", name);
  -        }
  -        if (!isWriteable())
  +        synchronized (this)
           {
  -            throw new FileSystemException("vfs.provider/create-folder-read-only.error", name);
  -        }
  +            if (getType() == FileType.FOLDER)
  +            {
  +                // Already exists as correct type
  +                return;
  +            }
  +            if (getType() != FileType.IMAGINARY)
  +            {
  +                throw new FileSystemException("vfs.provider/create-folder-mismatched-type.error", name);
  +            }
  +            if (!isWriteable())
  +            {
  +                throw new FileSystemException("vfs.provider/create-folder-read-only.error", name);
  +            }
   
  -        // Traverse up the heirarchy and make sure everything is a folder
  -        final FileObject parent = getParent();
  -        if (parent != null)
  -        {
  -            parent.createFolder();
  -        }
  +            // Traverse up the heirarchy and make sure everything is a folder
  +            final FileObject parent = getParent();
  +            if (parent != null)
  +            {
  +                parent.createFolder();
  +            }
   
  -        try
  -        {
  -            // Create the folder
  -            doCreateFolder();
  +            try
  +            {
  +                // Create the folder
  +                doCreateFolder();
   
  -            // Update cached info
  -            handleCreate(FileType.FOLDER);
  -        }
  -        catch (final RuntimeException re)
  -        {
  -            throw re;
  -        }
  -        catch (final Exception exc)
  -        {
  -            throw new FileSystemException("vfs.provider/create-folder.error", name, exc);
  +                // Update cached info
  +                handleCreate(FileType.FOLDER);
  +            }
  +            catch (final RuntimeException re)
  +            {
  +                throw re;
  +            }
  +            catch (final Exception exc)
  +            {
  +                throw new FileSystemException("vfs.provider/create-folder.error", name, exc);
  +            }
           }
       }
   
  @@ -1086,8 +1098,7 @@
        */
       public OutputStream getOutputStream(boolean bAppend) throws FileSystemException
       {
  -        attach();
  -        if (type != FileType.IMAGINARY && !type.hasContent())
  +        if (getType() != FileType.IMAGINARY && !getType().hasContent())
           {
               throw new FileSystemException("vfs.provider/write-not-file.error", name);
           }
  @@ -1100,7 +1111,7 @@
               throw new FileSystemException("vfs.provider/write-append-not-supported.error", name);
           }
   
  -        if (type == FileType.IMAGINARY)
  +        if (getType() == FileType.IMAGINARY)
           {
   // Does not exist - make sure parent does
               FileObject parent = getParent();
  @@ -1211,7 +1222,7 @@
        */
       protected void endOutput() throws Exception
       {
  -        if (type == FileType.IMAGINARY)
  +        if (getType() == FileType.IMAGINARY)
           {
               // File was created
               handleCreate(FileType.FILE);
  @@ -1229,23 +1240,26 @@
        */
       protected void handleCreate(final FileType newType) throws Exception
       {
  -        if (attached)
  +        synchronized (this)
           {
  -            // Fix up state
  -            type = newType;
  +            if (attached)
  +            {
  +                // Fix up state
  +                injectType(newType);
   
  -            removeChildrenCache();
  -            children = EMPTY_FILE_ARRAY;
  +                removeChildrenCache();
  +                children = EMPTY_FILE_ARRAY;
   
  -            // Notify subclass
  -            onChange();
  -        }
  +                // Notify subclass
  +                onChange();
  +            }
   
  -        // Notify parent that its child list may no longer be valid
  -        notifyParent();
  +            // Notify parent that its child list may no longer be valid
  +            notifyParent();
   
  -        // Notify the file system
  -        fs.fireFileCreated(this);
  +            // Notify the file system
  +            fs.fireFileCreated(this);
  +        }
       }
   
       /**
  @@ -1254,22 +1268,25 @@
        */
       protected void handleDelete() throws Exception
       {
  -        if (attached)
  +        synchronized (this)
           {
  -            // Fix up state
  -            type = FileType.IMAGINARY;
  -            removeChildrenCache();
  -            // children = null;
  +            if (attached)
  +            {
  +                // Fix up state
  +                injectType(FileType.IMAGINARY);
  +                removeChildrenCache();
  +                // children = null;
   
  -            // Notify subclass
  -            onChange();
  -        }
  +                // Notify subclass
  +                onChange();
  +            }
   
  -        // Notify parent that its child list may no longer be valid
  -        notifyParent();
  +            // Notify parent that its child list may no longer be valid
  +            notifyParent();
   
  -        // Notify the file system
  -        fs.fireFileDeleted(this);
  +            // Notify the file system
  +            fs.fireFileDeleted(this);
  +        }
       }
   
       /**
  
  
  
  1.23      +75 -43    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java
  
  Index: DefaultFileContent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DefaultFileContent.java	17 Jun 2004 19:29:28 -0000	1.22
  +++ DefaultFileContent.java	21 Dec 2004 21:54:32 -0000	1.23
  @@ -30,7 +30,6 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.security.cert.Certificate;
  -import java.util.ArrayList;
   import java.util.Collections;
   import java.util.Map;
   import java.util.Set;
  @@ -41,30 +40,37 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public final class DefaultFileContent
  -    implements FileContent
  +public final class DefaultFileContent implements FileContent
   {
  -    private static final int STATE_NONE = 0;
  -    private static final int STATE_READING = 1;
  -    private static final int STATE_WRITING = 2;
  -    private static final int STATE_RANDOM_ACCESS = 3;
  +    /*
  +    static final int STATE_NONE = 0;
  +    static final int STATE_READING = 1;
  +    static final int STATE_WRITING = 2;
  +    static final int STATE_RANDOM_ACCESS = 3;
  +    */
  +    static final int STATE_CLOSED = 0;
  +    static final int STATE_OPENED = 1;
   
       private final AbstractFileObject file;
  -    private int state = STATE_NONE;
  -    private final ArrayList instrs = new ArrayList();
  -    private FileContentOutputStream outstr;
       private Map attrs;
       private Map roAttrs;
       private FileContentInfo fileContentInfo;
       private final FileContentInfoFactory fileContentInfoFactory;
  -    private RandomAccessContent rastr;
  +
  +    private final ThreadLocal threadData = new ThreadLocal();
   
       public DefaultFileContent(final AbstractFileObject file, final FileContentInfoFactory fileContentInfoFactory)
       {
  +        this.threadData.set(new FileContentThreadData(this));
           this.file = file;
           this.fileContentInfoFactory = fileContentInfoFactory;
       }
   
  +    private FileContentThreadData getThreadData()
  +    {
  +        return (FileContentThreadData) this.threadData.get();
  +    }
  +
       /**
        * Returns the file that this is the content of.
        */
  @@ -83,10 +89,12 @@
           {
               throw new FileSystemException("vfs.provider/get-size-not-file.error", file);
           }
  -        if (state == STATE_WRITING || state == STATE_RANDOM_ACCESS)
  +        /*
  +        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
           {
               throw new FileSystemException("vfs.provider/get-size-write.error", file);
           }
  +        */
   
           try
           {
  @@ -104,10 +112,12 @@
        */
       public long getLastModifiedTime() throws FileSystemException
       {
  -        if (state == STATE_WRITING || state == STATE_RANDOM_ACCESS)
  +        /*
  +        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
           {
               throw new FileSystemException("vfs.provider/get-last-modified-writing.error", file);
           }
  +        */
           if (!file.getType().hasAttributes())
           {
               throw new FileSystemException("vfs.provider/get-last-modified-no-exist.error", file);
  @@ -127,10 +137,12 @@
        */
       public void setLastModifiedTime(final long modTime) throws FileSystemException
       {
  -        if (state == STATE_WRITING || state == STATE_RANDOM_ACCESS)
  +        /*
  +        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
           {
               throw new FileSystemException("vfs.provider/set-last-modified-writing.error", file);
           }
  +        */
           if (!file.getType().hasAttributes())
           {
               throw new FileSystemException("vfs.provider/set-last-modified-no-exist.error", file);
  @@ -223,10 +235,12 @@
           {
               throw new FileSystemException("vfs.provider/get-certificates-no-exist.error", file);
           }
  -        if (state == STATE_WRITING || state == STATE_RANDOM_ACCESS)
  +        /*
  +        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
           {
               throw new FileSystemException("vfs.provider/get-certificates-writing.error", file);
           }
  +        */
   
           try
           {
  @@ -251,16 +265,18 @@
        */
       public InputStream getInputStream() throws FileSystemException
       {
  -        if (state == STATE_WRITING || state == STATE_RANDOM_ACCESS)
  +        /*
  +        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
           {
               throw new FileSystemException("vfs.provider/read-in-use.error", file);
           }
  +        */
   
           // Get the raw input stream
           final InputStream instr = file.getInputStream();
           final InputStream wrappedInstr = new FileContentInputStream(instr);
  -        this.instrs.add(wrappedInstr);
  -        state = STATE_READING;
  +        this.getThreadData().addInstr(wrappedInstr);
  +        // setState(STATE_OPENED);
           return wrappedInstr;
       }
   
  @@ -270,16 +286,18 @@
        */
       public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
       {
  -        if (state != STATE_NONE)
  +        /*
  +        if (getThreadData().getState() != STATE_NONE)
           {
               throw new FileSystemException("vfs.provider/read-in-use.error", file);
           }
  +        */
   
           // Get the content
           final RandomAccessContent rastr = file.getRandomAccessContent(mode);
  -        this.rastr = new FileRandomAccessContent(rastr);
  -        state = STATE_RANDOM_ACCESS;
  -        return this.rastr;
  +        this.getThreadData().setRastr(new FileRandomAccessContent(rastr));
  +        // setState(STATE_OPENED);
  +        return this.getThreadData().getRastr();
       }
   
       /**
  @@ -295,7 +313,10 @@
        */
       public OutputStream getOutputStream(boolean bAppend) throws FileSystemException
       {
  -        if (state != STATE_NONE)
  +        /*
  +        if (getThreadData().getState() != STATE_NONE)
  +        */
  +        if (this.getThreadData().getOutstr() != null)
           {
               throw new FileSystemException("vfs.provider/write-in-use.error", file);
           }
  @@ -304,9 +325,9 @@
           final OutputStream outstr = file.getOutputStream(bAppend);
   
           // Create wrapper
  -        this.outstr = new FileContentOutputStream(outstr);
  -        state = STATE_WRITING;
  -        return this.outstr;
  +        this.getThreadData().setOutstr(new FileContentOutputStream(outstr));
  +        // setState(STATE_OPENED);
  +        return this.getThreadData().getOutstr();
       }
   
       /**
  @@ -315,27 +336,27 @@
        */
       public void close() throws FileSystemException
       {
  -        try
  +        // try
           {
               // Close the input stream
  -            while (instrs.size() > 0)
  +            while (getThreadData().getInstrsSize() > 0)
               {
  -                final FileContentInputStream instr = (FileContentInputStream) instrs.remove(0);
  +                final FileContentInputStream instr = (FileContentInputStream) getThreadData().removeInstr(0);
                   instr.close();
               }
   
               // Close the output stream
  -            if (outstr != null)
  +            if (this.getThreadData().getOutstr() != null)
               {
  -                outstr.close();
  +                this.getThreadData().getOutstr().close();
               }
   
               // Close the random access stream
  -            if (rastr != null)
  +            if (this.getThreadData().getRastr() != null)
               {
                   try
                   {
  -                    rastr.close();
  +                    this.getThreadData().getRastr().close();
                   }
                   catch (IOException e)
                   {
  @@ -343,10 +364,12 @@
                   }
               }
           }
  +        /*
           finally
           {
  -            state = STATE_NONE;
  +            setState(STATE_CLOSED);
           }
  +        */
       }
   
       /**
  @@ -354,11 +377,13 @@
        */
       private void endInput(final FileContentInputStream instr)
       {
  -        instrs.remove(instr);
  -        if (instrs.size() == 0)
  +        getThreadData().removeInstr(instr);
  +        /*
  +        if (!getThreadData().hasStreams())
           {
  -            state = STATE_NONE;
  +            setState(STATE_CLOSED);
           }
  +        */
       }
   
       /**
  @@ -366,7 +391,7 @@
        */
       private void endRandomAccess()
       {
  -        state = STATE_NONE;
  +        // setState(STATE_CLOSED);
       }
   
       /**
  @@ -374,11 +399,18 @@
        */
       private void endOutput() throws Exception
       {
  -        outstr = null;
  -        state = STATE_NONE;
  +        this.getThreadData().setOutstr(null);
  +        // setState(STATE_CLOSED);
           file.endOutput();
       }
   
  +    /*
  +    private void setState(int state)
  +    {
  +        getThreadData().setState(state);
  +    }
  +    */
  +
       /**
        * check if a input and/or output stream is open.
        *
  @@ -386,7 +418,8 @@
        */
       public boolean isOpen()
       {
  -        return state != STATE_NONE;
  +        // return getThreadData().getState() == STATE_OPENED;
  +        return getThreadData().hasStreams();
       }
   
       /**
  @@ -447,8 +480,7 @@
       /**
        * An output stream for writing content.
        */
  -    private final class FileContentOutputStream
  -        extends MonitorOutputStream
  +    final class FileContentOutputStream extends MonitorOutputStream
       {
           FileContentOutputStream(final OutputStream outstr)
           {
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/FileContentThreadData.java
  
  Index: FileContentThreadData.java
  ===================================================================
  package org.apache.commons.vfs.provider;
  
  import org.apache.commons.vfs.RandomAccessContent;
  
  import java.io.InputStream;
  import java.util.ArrayList;
  
  class FileContentThreadData
  {
      // private int state = DefaultFileContent.STATE_CLOSED;
  
      private final ArrayList instrs = new ArrayList();
      private DefaultFileContent.FileContentOutputStream outstr;
      private RandomAccessContent rastr;
  
      private final DefaultFileContent defaultFileContent;
  
      FileContentThreadData(DefaultFileContent defaultFileContent)
      {
          this.defaultFileContent = defaultFileContent;
      }
  
      /*
      int getState()
      {
          return state;
      }
  
      void setState(int state)
      {
          this.state = state;
      }
      */
  
      void addInstr(InputStream is)
      {
          this.instrs.add(is);
      }
  
      void setOutstr(DefaultFileContent.FileContentOutputStream os)
      {
          this.outstr = os;
      }
  
      DefaultFileContent.FileContentOutputStream getOutstr()
      {
          return this.outstr;
      }
  
      void setRastr(RandomAccessContent ras)
      {
          this.rastr = ras;
      }
  
      int getInstrsSize()
      {
          return this.instrs.size();
      }
  
      public Object removeInstr(int pos)
      {
          return this.instrs.remove(pos);
      }
  
      public void removeInstr(InputStream instr)
      {
          this.instrs.remove(instr);
      }
  
      public RandomAccessContent getRastr()
      {
          return this.rastr;
      }
  
      public boolean hasStreams()
      {
          return instrs.size() > 0 || outstr != null || rastr != null;
      }
  }
  
  
  
  1.38      +3 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
  
  Index: DefaultFileSystemManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- DefaultFileSystemManager.java	8 Nov 2004 21:07:43 -0000	1.37
  +++ DefaultFileSystemManager.java	21 Dec 2004 21:54:32 -0000	1.38
  @@ -24,7 +24,7 @@
   import org.apache.commons.vfs.FileSystemManager;
   import org.apache.commons.vfs.FileSystemOptions;
   import org.apache.commons.vfs.FilesCache;
  -import org.apache.commons.vfs.cache.DefaultFilesCache;
  +import org.apache.commons.vfs.cache.SoftRefFilesCache;
   import org.apache.commons.vfs.provider.AbstractFileProvider;
   import org.apache.commons.vfs.provider.DefaultURLStreamHandler;
   import org.apache.commons.vfs.provider.FileProvider;
  @@ -353,7 +353,8 @@
       {
           if (filesCache == null)
           {
  -            filesCache = new DefaultFilesCache();
  +            // filesCache = new DefaultFilesCache();
  +            filesCache = new SoftRefFilesCache();
           }
           if (fileContentInfoFactory == null)
           {
  
  
  
  1.11      +1 -0      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java
  
  Index: NestedZipTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- NestedZipTestCase.java	10 May 2004 20:09:50 -0000	1.10
  +++ NestedZipTestCase.java	21 Dec 2004 21:54:32 -0000	1.11
  @@ -50,6 +50,7 @@
       {
           manager.addProvider("zip", new ZipFileProvider());
           manager.addExtensionMap("zip", "zip");
  +        manager.addMimeTypeMap("application/zip", "zip");
       }
   
       /**
  
  
  
  1.10      +2 -0      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java
  
  Index: ZipProviderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ZipProviderTestCase.java	10 May 2004 20:09:51 -0000	1.9
  +++ ZipProviderTestCase.java	21 Dec 2004 21:54:32 -0000	1.10
  @@ -50,6 +50,8 @@
       public void prepare(final DefaultFileSystemManager manager) throws Exception
       {
           manager.addProvider("zip", new ZipFileProvider());
  +        manager.addExtensionMap("zip", "zip");
  +        manager.addMimeTypeMap("application/zip", "zip");
       }
   
       /**
  
  
  
  1.20      +4 -1      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java
  
  Index: ProviderWriteTests.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ProviderWriteTests.java	11 Oct 2004 19:27:53 -0000	1.19
  +++ ProviderWriteTests.java	21 Dec 2004 21:54:33 -0000	1.20
  @@ -24,7 +24,6 @@
   import org.apache.commons.vfs.FileType;
   import org.apache.commons.vfs.Selectors;
   
  -import java.io.InputStream;
   import java.io.OutputStream;
   import java.util.ArrayList;
   import java.util.HashSet;
  @@ -231,6 +230,7 @@
       /**
        * Tests concurrent read and write on the same file fails.
        */
  +    /* imario@apache.org leave this to some sort of LockManager
       public void testConcurrentReadWrite() throws Exception
       {
           final FileObject scratchFolder = createScratchFolder();
  @@ -257,10 +257,12 @@
               instr.close();
           }
       }
  +    */
   
       /**
        * Tests concurrent writes on the same file fails.
        */
  +    /* imario@apache.org leave this to some sort of LockManager
       public void testConcurrentWrite() throws Exception
       {
           final FileObject scratchFolder = createScratchFolder();
  @@ -293,6 +295,7 @@
           // Make sure that the content written to the first stream is actually applied
           assertSameContent(testContent, file);
       }
  +    */
   
       /**
        * Tests file copy to and from the same filesystem type.  This was a problem
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org