PR18522: [java] Fixed false positive for PreserveStackTraceRule when using builder pattern.
This commit is contained in:

committed by
Juan Martín Sotuyo Dodero

parent
0553073208
commit
38447ca3ee
@ -58,7 +58,8 @@ public class PreserveStackTraceRule extends AbstractJavaRule {
|
||||
// maybe it is used inside a anonymous class
|
||||
ck(data, target, throwStatement, parent);
|
||||
} else {
|
||||
ck(data, target, throwStatement, args);
|
||||
// Check all arguments used in the throw statement
|
||||
ck(data, target, throwStatement, throwStatement);
|
||||
}
|
||||
} else {
|
||||
Node child = throwStatement.jjtGetChild(0);
|
||||
|
@ -512,6 +512,27 @@ public class Bug {
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#422 False positive when using builder pattern</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.IOException;
|
||||
|
||||
public class Bug {
|
||||
void test() throws IOException {
|
||||
try {
|
||||
// do something
|
||||
} catch (final IOException e) {
|
||||
throw uncheckedException(ErrorCodeCommon.DIRECTORY_NOT_FOUND)
|
||||
.withField("dirname", dirname)
|
||||
.causedBy(e)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user