Skip to content

[IO-279] Add Tailer ignoreTouch option #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JoergBudi
Copy link
Contributor

@JoergBudi JoergBudi commented Jul 3, 2025

…oose to ignore touching of watched file

So I got late to the old io-279 Tailer issue. In the long history, some changes were already made long ago.
However from reading the last comments, some users want to avoid to get the whole file replayed
when the timestamp of the watched file changes without a content update. I added an ignoreTouch option, the default is false and resembles current behaviour (file gets replayed) (inspired from the 2015 patch by gh user myyron).
When changed to true via the Builder pattern, a newertimestamp with constant content gets ignored.
That makes the Tailer more similar to "tail -f" (issuing touch on the watched file is ignored then), but note that subtle differences remain. When you copy the identical file onto watched file, "tail -f" realizes that and replays the whole file. With ignoreTouch=true, the Tailer ignores that, as it looks identical to touching.

Added 2 Junit tests to verify both behaviours explictly.

@JoergBudi JoergBudi changed the title [WIP] [io-279] added ignoreOnTouch option to Tailer so that user can now ch… [io-279] added ignoreOnTouch option to Tailer so that user can now ch… Jul 3, 2025
@garydgregory garydgregory changed the title [io-279] added ignoreOnTouch option to Tailer so that user can now ch… [io-279] Add Tailer ignoreTouch option Jul 5, 2025
@garydgregory garydgregory changed the title [io-279] Add Tailer ignoreTouch option [IO-279] Add Tailer ignoreTouch option Jul 5, 2025
@garydgregory
Copy link
Member

@garydgregory garydgregory merged commit 42a86bd into apache:master Jul 5, 2025
18 of 21 checks passed
garydgregory added a commit that referenced this pull request Jul 5, 2025
@garydgregory
Copy link
Member

TY @JoergBudi !
Merged.

@garydgregory
Copy link
Member

@JoergBudi

One of the new test is unstable:

[INFO] Running org.apache.commons.io.input.TailerTest
Error:  Tests run: 27, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 22.21 s <<< FAILURE! -- in org.apache.commons.io.input.TailerTest
Error:  org.apache.commons.io.input.TailerTest.testTailerReissueOnTouch -- Time elapsed: 1.409 s <<< FAILURE!
org.opentest4j.AssertionFailedError: 1 line count ==> expected: <1> but was: <0>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
	at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:563)
	at org.apache.commons.io.input.TailerTest.testTailerReissueOnTouch(TailerTest.java:644)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)

Please see if you can re-write it with a count-down latch, or another sync technique.
TY!

@JoergBudi
Copy link
Contributor Author

@garydgregory I will work on the unstable test and try not to slow it down for the other platforms, I'll provide a new PR for that soon.

@JoergBudi JoergBudi deleted the bugfix/io-279-add-ignoreOnTouch-to-tailer branch July 5, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants