You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/09/30 04:30:47 UTC
svn commit: r1002933 -
/commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java
Author: sebb
Date: Thu Sep 30 02:30:47 2010
New Revision: 1002933
URL: http://svn.apache.org/viewvc?rev=1002933&view=rev
Log:
Original code kept the RAF if the re-open failed.
Revert to the same behaviour, but explicitly close the file
Modified:
commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java
Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java?rev=1002933&r1=1002932&r2=1002933&view=diff
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java (original)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/input/Tailer.java Thu Sep 30 02:30:47 2010
@@ -158,10 +158,14 @@ public class Tailer implements Runnable
// Reopen the reader after rotation
try {
- IOUtils.closeQuietly(reader);
+ // Ensure that the old file is closed iff we re-open it successfully
+ RandomAccessFile save = reader;
reader = new RandomAccessFile(file, "r");
position = 0;
+ // close old file explicitly rather than relying on GC picking up previous RAF
+ IOUtils.closeQuietly(save);
} catch (FileNotFoundException e) {
+ // in this case we continue to use the previous reader and position values
listener.fileNotFound();
}
continue;