diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java index 28c432a075..440998cc8e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java @@ -503,7 +503,7 @@ public class CloseResourceRule extends AbstractJavaRule { private boolean isDefaultFileSystem(ASTVariableId varId) { @Nullable ASTExpression initializer = varId.getInitializer(); - return initializer != null && initializer.getText().contentEquals("FileSystems.getDefault()"); + return initializer != null && InvocationMatcher.parse("java.nio.file.FileSystems#getDefault()").matchesCall(initializer); } private boolean isVariableSpecifiedInTryWithResource(ASTVariableId varId, ASTTryStatement tryWithResource) {