You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/03/10 19:15:00 UTC
[jira] [Commented] (IO-535) Thread bug in FileAlterationMonitor
[ https://issues.apache.org/jira/browse/IO-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16394305#comment-16394305 ]
ASF GitHub Bot commented on IO-535:
-----------------------------------
GitHub user SvetlinZarev opened a pull request:
https://github.com/apache/commons-io/pull/58
Fix IO-535
Fix IO-535
Adds test case to verify the incorrect behavior and the fix.
Does not incorrectly remove the Thread.currentThread().interrupt(); like the original PR (#36 ).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/SvetlinZarev/commons-io io-535
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-io/pull/58.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #58
----
commit 56a6496aebf960f0b19004d08d72b4c1a2d2b073
Author: Svetlin Zarev <sv...@...>
Date: 2018-03-10T18:37:30Z
Ignore IntelliJ IDE files
commit 967ec8505d0393d74ae2b80651b690b06ffe1ffb
Author: Svetlin Zarev <sv...@...>
Date: 2018-03-10T19:02:06Z
Add test case for IO-535
commit 22ead16c4e2d96ad5c0cf637e27f78479b2f0a04
Author: Svetlin Zarev <sv...@...>
Date: 2018-03-10T19:03:39Z
Fix IO-535
Interrupt the thread created by FileAlterationMonitor on stop()
----
> Thread bug in FileAlterationMonitor
> -----------------------------------
>
> Key: IO-535
> URL: https://issues.apache.org/jira/browse/IO-535
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.5
> Environment: Components managed by a DI Framework
> Reporter: Anthony RAYMOND
> Priority: Critical
> Labels: easyfix, patch, performance
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> The thread in FileAlterationMonitor wasn't stopped by the `stop(int)` method, which forbid application to shutdown until all `Thread` are exited (if FileAlterationMonitor is part of a DI managed component).
> This behavior conflict with the method javadoc `@param stopInterval the amount of time in milliseconds to wait for the thread to finish.`
> h5. Simple example to understand
> Bad behavior
> {code:java}
> Thread t = new Thread(() -> {
> try {
> Thread.sleep(500000);
> } catch (final InterruptedException e) {
> }
> });
> t.start();
> t.join(50);
> // Ok, we reach this point until 500000ms are elapsed, but the thread is still alive.
> // because Thread#join(int) does not kill the thread. And the thread remains alive.
> {code}
> Good behavior
> {code:java}
> Thread t = new Thread(() -> {
> try {
> Thread.sleep(500000);
> } catch (final InterruptedException e) {
> }
> });
> t.start();
> t.join(50);
> t.interupt();
> // Thread is exited
> {code}
> In this case, we waited the given time BEFORE exiting the `Thread`, as described in the javadoc, and the `Thread` is now finished and killed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)