Skip to content

FileUtils.foreceDelete consumed on Windows-System a lot of system resources #21

Description

@kaumein

The foreceDelete will consume on Windows system a lot of time, if it is called a lot of times for files which are not present on the file system.

The method did the following:
if ( !file.delete() ) {
if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) {
file = file.getCanonicalFile();
System.gc();
}
try {
Thread.sleep( 10 );
return file.delete();
} catch ( InterruptedException ignore ) {
return file.delete();
}
}

I suggest to have a look at the {{commons-io}} variant, which is much simpler and did not do any assumption on the opperation system.

A detailed blog entry can be found on my blog: https://kaffeeumeins.de/interesting-code-org-codehaus-plexus-util-fileutils-forcedeletefile

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions