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-exec.git
commit 69f8dbe0eb3b5df8094624e640a711a09e9b5887 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat May 24 10:58:27 2025 -0400 TimeoutObserver now extends Consumer<Watchdog> Next version will be 1.6.0 --- pom.xml | 6 +-- src/changes/changes.xml | 4 +- .../org/apache/commons/exec/TimeoutObserver.java | 14 ++++++- .../apache/commons/exec/TimeoutObserverTest.java} | 44 ++++++++++++++++------ 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index b58e702a..bd773295 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <name>Apache Commons Exec</name> <artifactId>commons-exec</artifactId> - <version>1.5.1-SNAPSHOT</version> + <version>1.6.0-SNAPSHOT</version> <inceptionYear>2005</inceptionYear> <description>Apache Commons Exec is a library that reliably executes external processes from within the JVM.</description> <url>https://commons.apache.org/proper/commons-exec/</url> @@ -50,8 +50,8 @@ limitations under the License. <maven.compiler.target>1.8</maven.compiler.target> <commons.rc.version>RC1</commons.rc.version> <commons.bc.version>1.5.0</commons.bc.version> - <commons.release.version>1.5.1</commons.release.version> - <commons.release.next>1.5.2</commons.release.next> + <commons.release.version>1.6.0</commons.release.version> + <commons.release.next>1.6.1</commons.release.next> <commons.release.isDistModule>true</commons.release.isDistModule> <commons.componentid>exec</commons.componentid> <commons.module.name>org.apache.commons.exec</commons.module.name> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 15da101e..1fb113fc 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -23,9 +23,11 @@ <title>Apache Commons Exec Release Notes</title> </properties> <body> - <release version="1.5.1" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required."> + <release version="1.6.0" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required."> <!-- FIX --> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Checkstyle issues.</action> <!-- ADD --> + <action type="add" dev="ggregory" due-to="Gary Gregory">TimeoutObserver now extends Consumer<Watchdog>.</action> <!-- UPDATE --> <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 83 to 84.</action> </release> diff --git a/src/main/java/org/apache/commons/exec/TimeoutObserver.java b/src/main/java/org/apache/commons/exec/TimeoutObserver.java index ccc56222..4bca85ed 100644 --- a/src/main/java/org/apache/commons/exec/TimeoutObserver.java +++ b/src/main/java/org/apache/commons/exec/TimeoutObserver.java @@ -19,12 +19,14 @@ package org.apache.commons.exec; +import java.util.function.Consumer; + /** * Interface for classes that want to be notified by Watchdog. * * @see org.apache.commons.exec.Watchdog */ -public interface TimeoutObserver { +public interface TimeoutObserver extends Consumer<Watchdog> { /** * Called when the watchdog times out. @@ -32,4 +34,14 @@ public interface TimeoutObserver { * @param w the watchdog that timed out. */ void timeoutOccured(Watchdog w); + + /** + * {@inheritDoc} + * + * @since 1.6.0 + */ + @Override + default void accept(final Watchdog w) { + timeoutOccured(w); + } } diff --git a/src/main/java/org/apache/commons/exec/TimeoutObserver.java b/src/test/java/org/apache/commons/exec/TimeoutObserverTest.java similarity index 52% copy from src/main/java/org/apache/commons/exec/TimeoutObserver.java copy to src/test/java/org/apache/commons/exec/TimeoutObserverTest.java index ccc56222..399857cd 100644 --- a/src/main/java/org/apache/commons/exec/TimeoutObserver.java +++ b/src/test/java/org/apache/commons/exec/TimeoutObserverTest.java @@ -19,17 +19,39 @@ package org.apache.commons.exec; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + /** - * Interface for classes that want to be notified by Watchdog. - * - * @see org.apache.commons.exec.Watchdog + * Tests {@link TimeoutObserver}. */ -public interface TimeoutObserver { - - /** - * Called when the watchdog times out. - * - * @param w the watchdog that timed out. - */ - void timeoutOccured(Watchdog w); +public class TimeoutObserverTest { + + static class TimeoutObserverFixture implements TimeoutObserver { + + private boolean b; + + @Override + public void timeoutOccured(final Watchdog w) { + b = true; + } + } + + private final TimeoutObserverFixture tof = new TimeoutObserverFixture(); + + @Test + public void testAccept() { + assertFalse(tof.b); + tof.accept(null); + assertTrue(tof.b); + } + + @Test + public void testTimeoutOccured() { + assertFalse(tof.b); + tof.timeoutOccured(null); + assertTrue(tof.b); + } }