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 78c4b2e27e41963dc63c087a38362d0ba68ca6de Author: Gary Gregory <[email protected]> AuthorDate: Wed Jan 28 08:23:34 2026 -0500 DefaultFileMonitor now restores the current thread's interrupt flag when catching InterruptedException. --- .../apache/commons/vfs2/impl/DefaultFileMonitor.java | 17 +++-------------- src/changes/changes.xml | 1 + 2 files changed, 4 insertions(+), 14 deletions(-) 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 5198d6fe8..0ae2b362b 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 @@ -336,22 +336,18 @@ public class DefaultFileMonitor implements Runnable, FileMonitor, AutoCloseable synchronized (monitorMap) { if (monitorMap.get(file.getName()) == null) { monitorMap.put(file.getName(), new FileMonitorAgent(this, file)); - try { if (listener != null) { file.getFileSystem().addListener(file, listener); } - if (file.getType().hasChildren() && recursive) { // Traverse the children // Add depth first Stream.of(file.getChildren()).forEach(this::addFile); } - } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } - } } } @@ -364,7 +360,7 @@ public class DefaultFileMonitor implements Runnable, FileMonitor, AutoCloseable try { monitorThread.join(); } catch (final InterruptedException e) { - // ignore + Thread.currentThread().interrupt(); } monitorThread = null; } @@ -451,9 +447,7 @@ public class DefaultFileMonitor implements Runnable, FileMonitor, AutoCloseable } catch (final FileSystemException fse) { parent = null; } - monitorMap.remove(fn); - if (parent != null) { // Not the root final FileMonitorAgent parentAgent = monitorMap.get(parent.getName()); if (parentAgent != null) { @@ -484,35 +478,30 @@ public class DefaultFileMonitor implements Runnable, FileMonitor, AutoCloseable if (agent != null) { agent.check(); } - if (getChecksPerRun() > 0 && (iterFileNames + 1) % getChecksPerRun() == 0) { try { Thread.sleep(getDelayDuration().toMillis()); } catch (final InterruptedException e) { - // Woke up. + Thread.currentThread().interrupt(); } } - if (monitorThread.isInterrupted() || !runFlag) { continue mainloop; } } - while (!addStack.empty()) { addFile(addStack.pop()); } - while (!deleteStack.empty()) { removeFile(deleteStack.pop()); } - try { Thread.sleep(getDelayDuration().toMillis()); } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); continue; } } - runFlag = true; } diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6505f5fe3..28f040b81 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -58,6 +58,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Guillaume Nodet, Gary Gregory">org.apache.commons.vfs2.provider.sftp.SftpClientFactory might now always resolve the current directory properly on Java 25.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Apache RAT plugin console warnings.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix build on Java 25, it's no longer experimental on GH CI.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">DefaultFileMonitor now restores the current thread's interrupt flag when catching InterruptedException.</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.sendOptions(String, String).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add FtpFileSystemConfigBuilder.getControlEncodingCharset(FileSystemOptions) and deprecate getControlEncoding(FileSystemOptions).</action>
