A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5067 below:

False positive for FileSystems.getDefault() · Issue #5067 · pmd/pmd · GitHub

Affects PMD Version:
7.2.0

Rule:
CloseResource
https://docs.pmd-code.org/latest/pmd_rules_java_errorprone.html#closeresource

Description:
Instances of FileSystems.getDefault() trigger that rule. As per the javadoc for java.nio.file.FileSystem: The default file system cannot be closed. Trying to close the default file system would throw an UnsupportedOperationException.

Code Sample demonstrating the issue:

public class Example {
    public static void main(String[] args) {
        final var fs = FileSystems.getDefault();
    }
}

Expected outcome:

PMD reports a violation at line 3, but that's wrong. That's a false positive.

Running PMD through: Gradle


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4