[java] UseTryWithResources: Fix false negative
This commit is contained in:
@ -1465,7 +1465,7 @@ preserved.
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//TryStatement[not(ResourceSpecification)][FinallyStatement//Name[
|
||||
//TryStatement[FinallyStatement//Name[
|
||||
tokenize(@Image, '\.')[last()] = $closeMethods
|
||||
]]
|
||||
]]>
|
||||
|
@ -141,4 +141,21 @@ public class TryWithResources {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>False negative with two resources</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>4</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class TryWithResources {
|
||||
public void run() {
|
||||
Reader r1 = new FileReader(file);
|
||||
try (Reader r2 = new FileReader(otherFile)) {
|
||||
} finally {
|
||||
r1.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user