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 2005/09/05 11:54:46 UTC

svn commit: r278705 - in /jakarta/commons/proper/vfs/trunk: RELEASE_NOTES.txt src/java/org/apache/commons/vfs/provider/DefaultFileContent.java

Author: imario
Date: Mon Sep  5 02:54:38 2005
New Revision: 278705

URL: http://svn.apache.org/viewcvs?rev=278705&view=rev
Log:
fix: avoid gc when referencing only inputStream/outputStream of a fileObject

Modified:
    jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java

Modified: jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt?rev=278705&r1=278704&r2=278705&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt Mon Sep  5 02:54:38 2005
@@ -1,5 +1,8 @@
 2005-
 
+threading:
+avoid gc when referencing only inputStream/outputStream of a fileObject
+
 filenames:
 add a type (file/folder) to filename.
 This is needed to allow URI style filename resolving

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java?rev=278705&r1=278704&r2=278705&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/DefaultFileContent.java Mon Sep  5 02:54:38 2005
@@ -279,7 +279,7 @@
 
         // Get the raw input stream
         final InputStream instr = file.getInputStream();
-        final InputStream wrappedInstr = new FileContentInputStream(instr);
+        final InputStream wrappedInstr = new FileContentInputStream(file, instr);
         this.getThreadData().addInstr(wrappedInstr);
         // setState(STATE_OPENED);
         return wrappedInstr;
@@ -300,7 +300,7 @@
 
         // Get the content
         final RandomAccessContent rastr = file.getRandomAccessContent(mode);
-        this.getThreadData().setRastr(new FileRandomAccessContent(rastr));
+        this.getThreadData().setRastr(new FileRandomAccessContent(file, rastr));
         // setState(STATE_OPENED);
         return this.getThreadData().getRastr();
     }
@@ -330,7 +330,7 @@
         final OutputStream outstr = file.getOutputStream(bAppend);
 
         // Create wrapper
-        this.getThreadData().setOutstr(new FileContentOutputStream(outstr));
+        this.getThreadData().setOutstr(new FileContentOutputStream(file, outstr));
         // setState(STATE_OPENED);
         return this.getThreadData().getOutstr();
     }
@@ -433,9 +433,13 @@
     private final class FileContentInputStream
         extends MonitorInputStream
     {
-        FileContentInputStream(final InputStream instr)
+        // avoid gc
+        private final FileObject file;
+
+        FileContentInputStream(final FileObject file, final InputStream instr)
         {
             super(instr);
+            this.file = file;
         }
 
         /**
@@ -474,9 +478,13 @@
      */
     private final class FileRandomAccessContent extends MonitorRandomAccessContent
     {
-        FileRandomAccessContent(final RandomAccessContent content)
+        // avoid gc
+        private final FileObject file;
+
+        FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
         {
             super(content);
+            this.file = file;
         }
 
         /**
@@ -500,9 +508,13 @@
      */
     final class FileContentOutputStream extends MonitorOutputStream
     {
-        FileContentOutputStream(final OutputStream outstr)
+        // avoid gc
+        private final FileObject file;
+
+        FileContentOutputStream(final FileObject file, final OutputStream outstr)
         {
             super(outstr);
+            this.file = file;
         }
 
         /**



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