issue-1701 fix bug to suppress false positive in useTryWithResources when close method have multiple arguments
This commit is contained in:
@@ -1657,7 +1657,7 @@ preserved.
|
||||
][
|
||||
pmd-java:typeIs('java.lang.AutoCloseable')
|
||||
or
|
||||
../../PrimarySuffix/Arguments[@ArgumentCount = 1]//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')]
|
||||
../../PrimarySuffix/Arguments//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')]
|
||||
]]
|
||||
```
|
||||
|
||||
|
@@ -1546,7 +1546,7 @@ preserved.
|
||||
][
|
||||
pmd-java:typeIs('java.lang.AutoCloseable')
|
||||
or
|
||||
../../PrimarySuffix/Arguments[@ArgumentCount = 1]//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')]
|
||||
../../PrimarySuffix/Arguments//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')]
|
||||
]]
|
||||
]]>
|
||||
</value>
|
||||
|
@@ -189,4 +189,28 @@ public class TryWithResources {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>Custom close methods with multiple arguments</description>
|
||||
<rule-property name="closeMethods">myClose2,myClose</rule-property>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>6</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
import java.io.*;
|
||||
|
||||
public class TryWithResources {
|
||||
public void run() {
|
||||
InputStream in = null, in2 = null;
|
||||
try {
|
||||
in = openInputStream();
|
||||
in2 = openInputStream();
|
||||
int i = in.read(), j = in2.read();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
myClose(in, in2);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user