Re: [io][fileupload] svn commit: r518770 - in /jakarta/commons/proper/io/trunk/src: java/org/apache/commons/io/FileCleaningTracker.java test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java

2007-06-07 Thread Rahul Akolkar

On 6/6/07, Jochen Wiedmann <[EMAIL PROTECTED]> wrote:

On 3/16/08, Rahul Akolkar wrote:

> On 3/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Author: jochen
> > Date: Thu Mar 15 15:02:46 2007
> > New Revision: 518770
> >




I haven't really though about the fileupload part, but you have
convinced me that this must be addressed by fileupload and not by io.
I have therefore reverted my patch in the 1.3 branch. I will also
revert the same patch in the trunk after the 1.3.2 release is out when
I merge the release related changes in.




OK, thanks.

-Rahul



Jochen



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [io][fileupload] svn commit: r518770 - in /jakarta/commons/proper/io/trunk/src: java/org/apache/commons/io/FileCleaningTracker.java test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java

2007-06-06 Thread Jochen Wiedmann

On 3/16/08, Rahul Akolkar wrote:


On 3/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Author: jochen
> Date: Thu Mar 15 15:02:46 2007
> New Revision: 518770
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=518770
> Log:
> Made the FileCleaningTracker serializable.
> This is required by commons-fileupload, because the
> DiskFileItem's may be part of the HTTP session while
> still carrying a reference to the tracker.
>




I think this particular solution is sub-optimal in a couple of aspects:



 * The instances aren't really serializable so its a bit of a truth in
advertising infringement
 * Its introducing a tighter coupling between the next releases of
[io] and [fileupload], which is fine if we can buy that there is
evidence that the change would be helpful to [io] in isolation.



I think identical behavior (for what this is worth) can be obtained by
reverting this commit and having a transient lazily-initialized
FileCleaningTracker in DiskFileItem, which addresses the two bullets
above, and the NotSerializableExceptions that you may otherwise
witness at container shutdown.



WDYT?


I haven't really though about the fileupload part, but you have
convinced me that this must be addressed by fileupload and not by io.
I have therefore reverted my patch in the 1.3 branch. I will also
revert the same patch in the trunk after the 1.3.2 release is out when
I merge the release related changes in.

Jochen

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [io][fileupload] svn commit: r518770 - in /jakarta/commons/proper/io/trunk/src: java/org/apache/commons/io/FileCleaningTracker.java test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java

2007-03-16 Thread Rahul Akolkar

On 3/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Author: jochen
Date: Thu Mar 15 15:02:46 2007
New Revision: 518770

URL: http://svn.apache.org/viewvc?view=rev&rev=518770
Log:
Made the FileCleaningTracker serializable.
This is required by commons-fileupload, because the
DiskFileItem's may be part of the HTTP session while
still carrying a reference to the tracker.




I think this particular solution is sub-optimal in a couple of aspects:

* The instances aren't really serializable so its a bit of a truth in
advertising infringement
* Its introducing a tighter coupling between the next releases of
[io] and [fileupload], which is fine if we can buy that there is
evidence that the change would be helpful to [io] in isolation.

I think identical behavior (for what this is worth) can be obtained by
reverting this commit and having a transient lazily-initialized
FileCleaningTracker in DiskFileItem, which addresses the two bullets
above, and the NotSerializableExceptions that you may otherwise
witness at container shutdown.

WDYT?

-Rahul



Modified:

jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaningTracker.java

jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java

Modified: 
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaningTracker.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaningTracker.java?view=diff&rev=518770&r1=518769&r2=518770
==
--- 
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaningTracker.java
 (original)
+++ 
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaningTracker.java
 Thu Mar 15 15:02:46 2007
@@ -17,6 +17,8 @@
 package org.apache.commons.io;

 import java.io.File;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
 import java.lang.ref.PhantomReference;
 import java.lang.ref.ReferenceQueue;
 import java.util.Collection;
@@ -40,23 +42,28 @@
  * @author Martin Cooper
  * @version $Id: FileCleaner.java 490987 2006-12-29 12:11:48Z scolebourne $
  */
-public class FileCleaningTracker {
+public class FileCleaningTracker implements Serializable {
+/**
+ * UID for serializing instances of this class.
+ */
+private static final long serialVersionUID = -8153509976492548871L;
+
 /**
  * Queue of Tracker instances being watched.
  */
-ReferenceQueue /* Tracker */ q = new ReferenceQueue();
+transient ReferenceQueue /* Tracker */ q = new ReferenceQueue();
 /**
  * Collection of Tracker instances in existence.
  */
-final Collection /* Tracker */ trackers = new Vector();  // synchronized
+final transient Collection /* Tracker */ trackers = new Vector();  // 
synchronized
 /**
  * Whether to terminate the thread when the tracking is complete.
  */
-volatile boolean exitWhenFinished = false;
+transient volatile boolean exitWhenFinished = false;
 /**
  * The thread that will clean up registered files.
  */
-Thread reaper;
+transient Thread reaper;

 //---
 /**
@@ -255,4 +262,14 @@
 }
 }

+/**
+ * This method is called when an instance is deserialized.
+ * It replaces the deserialized instance with a new, fresh
+ * instance.
+ * @return A new instance, which hasn't been in use so far.
+ * @throws ObjectStreamException Not actually thrown.
+ */
+private Object readResolve() throws ObjectStreamException {
+return new FileCleaningTracker();
+}
 }

Modified: 
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java?view=diff&rev=518770&r1=518769&r2=518770
==
--- 
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
 (original)
+++ 
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
 Thu Mar 15 15:02:46 2007
@@ -103,7 +103,7 @@
 }

 public void testThrowsOnNullList() throws Exception {
-if (!chmod(top, 0, false)) {
+if (System.getProperty("os.name").startsWith("Win")  ||  !chmod(top, 
0, false)) {
 // test wont work if we can't restrict permissions on the
 // directory, so skip it.
 return;
@@ -122,7 +122,7 @@
 final File file = new File(top, "restricted");
 FileUtils.touch(file);

-if (!chmod(top, 500, false)) {
+if (System.getProperty("os.name").startsWith("Win")  ||  !chmod(top, 
500, false)) {
 // test wont work if we can't re