Skip to content

[MSHARED-1122] FileUtils: avoid getCanonicalPath() #320

Closed

Description

@jira-importer

Jörg Kubitz opened MSHARED-1122 and commented

On JDK 11 the result has been cached with in JVM.
Since JDK 12 the result is not cached anymore by default (See https://bugs.openjdk.java.net/browse/JDK-8207005) and now very slow on windows.

For org.apache.maven.shared.utils.io.FileUtils.copyFile(File, File)
please use java.nio.file.Files.isSameFile(Path, Path) instead.

note: it's needed to call file.exists() before using Files.isSameFile() or catch NoSuchFileException 

@see

https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/180308/10/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java

for a similar fix.

Here is a screenshot of sampling eclipse showing getCanonicalPath() as a hotspot:

!image-2022-08-22-18-18-52-811.png!


Attachments:

Remote Links:

Backported to: maven-shared-utils-3.4.0

Activity

  1. jira-importer commented on Aug 22, 2022

    @jira-importer
    Author

    Jörg Kubitz commented

    proposed fix tested with org.apache.maven.shared.utils.io.FileUtilsTest.copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()

  2. jira-importer commented on Sep 13, 2022

    @jira-importer
    Author

    Slawomir Jaranowski commented

    By the way FileUtils#copyFile is deprecated ...

  3. added
    enhancementNew feature or request
    priority:minorMinor loss of function, or other problem where easy workaround is present
    on Jul 3, 2025
  4. removed
    priority:minorMinor loss of function, or other problem where easy workaround is present
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions