apache / apache/maven-mvnd

FileSystemException when trying to purge

Open
#1,318 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
3.5k
Forks
250
Avg merge
16h 22m
Merged PRs (30d)
36

Description

### Affected version

1.0.2 (windows)

### Bug description

Hello,

I am using mvnd from within VSCode through a filewatcher.

Here is the command executed :
```
for /f "usebackq tokens=*" %d in (`git -C "xxxx" rev-parse --show-toplevel`) do mvnd -q spotless:apply -f "%d" -DspotlessFiles=".*\\beans.xml$"
```

Here is the output I get :
```
[error] Apr 28, 2025 2:34:31 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
[main] WARNING org.jline - Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Purged 0 log files with 4 exceptions (log available in C:\Users\xxx\.m2\mvnd\registry\1.0.2\purge-2025-04-28.log)
```

When looking at "purge-2025-04-28.log" file I can see :
```
Purge executed at 2025-04-28T12:34:34.668944200Z
No files deleted.
4 exception(s) occurred during the purgejava.nio.file.FileSystemException: C:\Users\xxx\.m2\mvnd\registry\1.0.2\daemon-b4f3270f.log: The process cannot access the file because it is being used by another process
at java.base@22.0.2/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:273)
at java.base@22.0.2/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:104)
at java.base@22.0.2/java.nio.file.Files.delete(Files.java:1152)
at org.mvndaemon.mvnd.client.DefaultClient.lambda$purgeLogs$11(DefaultClient.java:436)
[...3 more times]
```
even if I do not have any other process running or touching those files

I have also tried to prefix the command with "set org.jline.terminal.dumb=true &&" but it does not change anything.
Any idea why the purge fail and how it could be fixed?

Thank you

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at org.mvndaemon.mvnd.client.DefaultClient.purgeLogs, where the WindowsFileSystemProvider exception occurs, and reproduce the reported mvnd 1.0.2 command on Windows. The fix is complete when purging registry log files no longer reports FileSystemException for files that are still open by mvnd.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.