Author: sebb Date: Thu Jun 7 23:54:49 2012 New Revision: 1347836 URL: http://svn.apache.org/viewvc?rev=1347836&view=rev Log: IO-279 - Tailer erroneously considers file as new.
Modified: commons/proper/io/trunk/src/changes/changes.xml commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java Modified: commons/proper/io/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/changes/changes.xml?rev=1347836&r1=1347835&r2=1347836&view=diff ============================================================================== --- commons/proper/io/trunk/src/changes/changes.xml (original) +++ commons/proper/io/trunk/src/changes/changes.xml Thu Jun 7 23:54:49 2012 @@ -47,6 +47,9 @@ The <action> type attribute can be add,u <body> <!-- The release date is the date RC is cut --> <release version="2.4" date="2012-TDB-TDB" description=""> + <action issue="IO-279" dev="sebb" type="fix" due-to="Sergio Bossa, Chris Baron"> + Tailer erroneously considers file as new. + </action> <action issue="IO-335" dev="sebb" type="fix"> Tailer#readLines - incorrect CR handling. </action> Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java?rev=1347836&r1=1347835&r2=1347836&view=diff ============================================================================== --- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java (original) +++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java Thu Jun 7 23:54:49 2012 @@ -297,6 +297,8 @@ public class Tailer implements Runnable while (run) { + boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first + // Check the file length to see if it was rotated long length = file.length(); @@ -326,10 +328,10 @@ public class Tailer implements Runnable if (length > position) { // The file has more content than it did last time - last = System.currentTimeMillis(); position = readLines(reader); + last = System.currentTimeMillis(); - } else if (FileUtils.isFileNewer(file, last)) { + } else if (newer) { /* * This can happen if the file is truncated or overwritten with the exact same length of @@ -339,8 +341,8 @@ public class Tailer implements Runnable reader.seek(position); // cannot be null here // Now we can read new lines - last = System.currentTimeMillis(); position = readLines(reader); + last = System.currentTimeMillis(); } } try {