This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit 86b6583cc29a09f14e16f92c048beb59da1720d0 Author: Gary Gregory <[email protected]> AuthorDate: Fri Nov 26 10:34:49 2021 -0500 Add DefaultFileMonitor.setDelay(Duration), getDelayDuration() and deprecate setDelay(long), getDelay(). Update version from 2.9.1-SNAPSHOT to 2.10.0-SNAPSHOT. --- commons-vfs2-distribution/pom.xml | 2 +- commons-vfs2-examples/pom.xml | 2 +- commons-vfs2-jackrabbit1/pom.xml | 2 +- commons-vfs2-jackrabbit2/pom.xml | 2 +- commons-vfs2-sandbox/pom.xml | 2 +- commons-vfs2/pom.xml | 2 +- .../commons/vfs2/impl/DefaultFileMonitor.java | 34 ++++++++++++++++++---- pom.xml | 2 +- src/changes/changes.xml | 3 ++ 9 files changed, 39 insertions(+), 12 deletions(-) diff --git a/commons-vfs2-distribution/pom.xml b/commons-vfs2-distribution/pom.xml index 70954e8..68e5c8d 100644 --- a/commons-vfs2-distribution/pom.xml +++ b/commons-vfs2-distribution/pom.xml @@ -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> diff --git a/commons-vfs2-examples/pom.xml b/commons-vfs2-examples/pom.xml index af2de1d..69c83b5 100644 --- a/commons-vfs2-examples/pom.xml +++ b/commons-vfs2-examples/pom.xml @@ -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> diff --git a/commons-vfs2-jackrabbit1/pom.xml b/commons-vfs2-jackrabbit1/pom.xml index 30b30d8..4939987 100644 --- a/commons-vfs2-jackrabbit1/pom.xml +++ b/commons-vfs2-jackrabbit1/pom.xml @@ -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> diff --git a/commons-vfs2-jackrabbit2/pom.xml b/commons-vfs2-jackrabbit2/pom.xml index 607c089..7ee27b1 100644 --- a/commons-vfs2-jackrabbit2/pom.xml +++ b/commons-vfs2-jackrabbit2/pom.xml @@ -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> diff --git a/commons-vfs2-sandbox/pom.xml b/commons-vfs2-sandbox/pom.xml index b9f63f9..028a03b 100644 --- a/commons-vfs2-sandbox/pom.xml +++ b/commons-vfs2-sandbox/pom.xml @@ -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> diff --git a/commons-vfs2/pom.xml b/commons-vfs2/pom.xml index 73815c3..9920f52 100644 --- a/commons-vfs2/pom.xml +++ b/commons-vfs2/pom.xml @@ -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> diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java index 0af057b..db04237 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java @@ -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 @@ public class DefaultFileMonitor implements Runnable, FileMonitor { 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 @@ public class DefaultFileMonitor implements Runnable, FileMonitor { /** * 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 class DefaultFileMonitor implements Runnable, FileMonitor { /** * 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 class DefaultFileMonitor implements Runnable, FileMonitor { 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 class DefaultFileMonitor implements Runnable, FileMonitor { * 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); } /** diff --git a/pom.xml b/pom.xml index 1898001..ca8e4dd 100644 --- a/pom.xml +++ b/pom.xml @@ -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> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2e499ec..48dd245 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -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.
