Skip to content

Commit 7705470

Browse files
committed
IO-279 Tailer erroneously considers file as new.
Fix to use file.lastModified() rather than System.currentTimeMillis() git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1476097 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9afc296 commit 7705470

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/changes/changes.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ The <action> type attribute can be add,update,fix,remove.
4747
<body>
4848
<!-- The release date is the date RC is cut -->
4949
<release version="2.5" date="2013-??-??" description="New features and bug fixes.">
50+
<action issue="IO-279" dev="sebb" type="fix">
51+
Tailer erroneously considers file as new.
52+
Fix to use file.lastModified() rather than System.currentTimeMillis()
53+
</action>
5054
<action issue="IO-356" dev="sebb" type="fix">
5155
CharSequenceInputStream#reset() behaves incorrectly in case when buffer size is not dividable by data size.
5256
Fix code so skip relates to the encoded bytes; reset now re-encodes the data up to the point of the mark

src/main/java/org/apache/commons/io/input/Tailer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public void run() {
363363
} else {
364364
// The current position in the file
365365
position = end ? file.length() : 0;
366-
last = System.currentTimeMillis();
366+
last = file.lastModified();
367367
reader.seek(position);
368368
}
369369
}
@@ -400,7 +400,7 @@ public void run() {
400400
if (length > position) {
401401
// The file has more content than it did last time
402402
position = readLines(reader);
403-
last = System.currentTimeMillis();
403+
last = file.lastModified();
404404
} else if (newer) {
405405
/*
406406
* This can happen if the file is truncated or overwritten with the exact same length of
@@ -411,7 +411,7 @@ public void run() {
411411

412412
// Now we can read new lines
413413
position = readLines(reader);
414-
last = System.currentTimeMillis();
414+
last = file.lastModified();
415415
}
416416
}
417417
if (reOpen) {

0 commit comments

Comments
 (0)