Skip to content

Commit ce20baf

Browse files
committed
Setting builder delay duration to null acts as a reset.
1 parent a56fcff commit ce20baf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ public class Tailer implements Runnable, AutoCloseable {
175175
*/
176176
public static class Builder extends AbstractStreamBuilder<Tailer, Builder> {
177177

178+
private static final Duration DEFAULT_DELAY_DURATION = Duration.ofMillis(DEFAULT_DELAY_MILLIS);
179+
178180
/**
179181
* Creates a new daemon thread.
180182
*
@@ -189,7 +191,7 @@ private static Thread newDaemonThread(final Runnable runnable) {
189191

190192
private Tailable tailable;
191193
private TailerListener tailerListener;
192-
private Duration delayDuration = Duration.ofMillis(DEFAULT_DELAY_MILLIS);
194+
private Duration delayDuration = DEFAULT_DELAY_DURATION;
193195
private boolean end;
194196
private boolean reOpen;
195197
private boolean startThread = true;
@@ -212,13 +214,13 @@ public Tailer get() {
212214
}
213215

214216
/**
215-
* Sets the delay duration.
217+
* Sets the delay duration. null resets to the default delay of one second.
216218
*
217219
* @param delayDuration the delay between checks of the file for new content.
218220
* @return this
219221
*/
220222
public Builder setDelayDuration(final Duration delayDuration) {
221-
this.delayDuration = Objects.requireNonNull(delayDuration, "delayDuration");
223+
this.delayDuration = delayDuration != null ? delayDuration : DEFAULT_DELAY_DURATION;
222224
return this;
223225
}
224226

@@ -229,7 +231,7 @@ public Builder setDelayDuration(final Duration delayDuration) {
229231
* @return this
230232
*/
231233
public Builder setExecutorService(final ExecutorService executorService) {
232-
this.executorService = executorService;
234+
this.executorService = Objects.requireNonNull(executorService, "executorService");;
233235
return this;
234236
}
235237

0 commit comments

Comments
 (0)