[
https://issues.apache.org/jira/browse/IO-889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ilya Basin updated IO-889:
--------------------------
Description:
On Windows after Tailer.close() the watched file cannot be moved or deleted
immediately and Tailer does not provide any additional means to wait for the
submitted executor task. I believe that when no custom executor or thread is
used there still should be a way to wait with desired timeout. I understand
that close() isn't the perfect method for waiting. How about extending Tailer
from FutureTask?
My current workaround is to avoid using executors and just create
java.lang.Thread and call Thread.join() afterwards.
Attached a test case: [^TailerCloseTest.java]
^Expected: test succeeds^
^Actual: Files.delete() fails^
{code:java}
java.nio.file.FileSystemException:
C:\Users\basin\AppData\Local\Temp\TailerTestFile551954280413046718.log: The
process cannot access the file because it is being used by another process.
at
java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
at
java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at
java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at
java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:274)
at
java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
at java.base/java.nio.file.Files.delete(Files.java:1142)
at
org.apache.commons.io.input.TailerCloseTest.testCloseTailer(TailerCloseTest.java:60)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541){code}
was:
On Windows after Tailer.close() the watched file cannot be moved or deleted
immediately and Tailer does not provide any additional means to wait for the
submitted executor task. I believe that when no custom executor or thread is
used there still should be a way to wait with desired timeout. I understand
that close() isn't the perfect method for waiting.
My current workaround is to avoid using executors and just create
java.lang.Thread and call Thread.join() afterwards.
Attached a test case: [^TailerCloseTest.java]
^Expected: test succeeds^
^Actual: Files.delete() fails^
{code:java}
java.nio.file.FileSystemException:
C:\Users\basin\AppData\Local\Temp\TailerTestFile551954280413046718.log: The
process cannot access the file because it is being used by another process.
at
java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
at
java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at
java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at
java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:274)
at
java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
at java.base/java.nio.file.Files.delete(Files.java:1142)
at
org.apache.commons.io.input.TailerCloseTest.testCloseTailer(TailerCloseTest.java:60)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541){code}
> Tailer.close() does not guarantee file close
> --------------------------------------------
>
> Key: IO-889
> URL: https://issues.apache.org/jira/browse/IO-889
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.21.0
> Environment: Windows
> Reporter: Ilya Basin
> Priority: Major
> Attachments: TailerCloseTest.java
>
>
> On Windows after Tailer.close() the watched file cannot be moved or deleted
> immediately and Tailer does not provide any additional means to wait for the
> submitted executor task. I believe that when no custom executor or thread is
> used there still should be a way to wait with desired timeout. I understand
> that close() isn't the perfect method for waiting. How about extending Tailer
> from FutureTask?
> My current workaround is to avoid using executors and just create
> java.lang.Thread and call Thread.join() afterwards.
> Attached a test case: [^TailerCloseTest.java]
> ^Expected: test succeeds^
> ^Actual: Files.delete() fails^
>
> {code:java}
> java.nio.file.FileSystemException:
> C:\Users\basin\AppData\Local\Temp\TailerTestFile551954280413046718.log: The
> process cannot access the file because it is being used by another process.
> at
> java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
> at
> java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
> at
> java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
> at
> java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:274)
> at
> java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
> at java.base/java.nio.file.Files.delete(Files.java:1142)
> at
> org.apache.commons.io.input.TailerCloseTest.testCloseTailer(TailerCloseTest.java:60)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1541){code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)