Skip to content
Permalink
Browse files
Add DefaultFileMonitor.setDelay(Duration), getDelayDuration() and
deprecate setDelay(long), getDelay().

Update version from 2.9.1-SNAPSHOT to 2.10.0-SNAPSHOT.
  • Loading branch information
garydgregory committed Nov 26, 2021
1 parent 1a92b8c commit 86b6583cc29a09f14e16f92c048beb59da1720d0
Showing 9 changed files with 39 additions and 12 deletions.
@@ -28,7 +28,7 @@ limitations under the License.
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -29,7 +29,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2-project</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@@ -16,6 +16,7 @@
*/
package org.apache.commons.vfs2.impl;

import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
@@ -266,7 +267,7 @@ private void resetChildrenList() {

private static final Log LOG = LogFactory.getLog(DefaultFileMonitor.class);

private static final long DEFAULT_DELAY = 1000;
private static final Duration DEFAULT_DELAY = Duration.ofSeconds(1);

private static final int DEFAULT_MAX_FILES = 1000;

@@ -303,7 +304,7 @@ private void resetChildrenList() {
/**
* Set the delay between checks
*/
private long delay = DEFAULT_DELAY;
private Duration delay = DEFAULT_DELAY;

/**
* Set the number of files to check until a delay will be inserted
@@ -368,9 +369,20 @@ public int getChecksPerRun() {
/**
* Gets the delay between runs.
*
* @return The delay period.
* @return The delay period in milliseconds.
* @deprecated Use {@link #getDelayDuration()}.
*/
@Deprecated
public long getDelay() {
return delay.toMillis();
}

/**
* Gets the delay between runs.
*
* @return The delay period.
*/
public Duration getDelayDuration() {
return delay;
}

@@ -462,7 +474,7 @@ public void run() {

if (getChecksPerRun() > 0 && (iterFileNames + 1) % getChecksPerRun() == 0) {
try {
Thread.sleep(getDelay());
Thread.sleep(getDelayDuration().toMillis());
} catch (final InterruptedException e) {
// Woke up.
}
@@ -504,9 +516,21 @@ public void setChecksPerRun(final int checksPerRun) {
* Sets the delay between runs.
*
* @param delay The delay period.
* @since 2.10.0
*/
public void setDelay(final Duration delay) {
this.delay = delay == null || delay.isNegative() ? DEFAULT_DELAY : delay;
}

/**
* Sets the delay between runs.
*
* @param delay The delay period in milliseconds.
* @deprecated Use {@link #setDelay(Duration)}.
*/
@Deprecated
public void setDelay(final long delay) {
this.delay = delay > 0 ? delay : DEFAULT_DELAY;
setDelay(delay > 0 ? Duration.ofMillis(delay) : DEFAULT_DELAY);
}

/**
@@ -29,7 +29,7 @@
<name>Apache Commons VFS Project</name>
<description>Apache Commons VFS is a Virtual File System library.</description>
<packaging>pom</packaging>
<version>2.9.1-SNAPSHOT</version>
<version>2.10.0-SNAPSHOT</version>

<url>http://commons.apache.org/proper/commons-vfs/</url>
<inceptionYear>2002</inceptionYear>
@@ -72,6 +72,9 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Seth Falco">
Add vscode files to gitignore #205.
</action>
<action type="add" dev="ggregory" due-to="Seth Falco">
Add DefaultFileMonitor.setDelay(Duration), getDelayDuration() and deprecate setDelay(long), getDelay().
</action>
<!-- UDPATE -->
<action type="update" dev="ggregory" due-to="Dependabot">
Bump jakarta.mail from 1.6.7 to 2.0.1 #200.

0 comments on commit 86b6583

Please sign in to comment.