PR18522: [java] Fixed false positive for PreserveStackTraceRule when using builder pattern.

This commit is contained in:
dreniers
2017-06-06 13:43:37 +02:00
committed by Juan Martín Sotuyo Dodero
parent 0553073208
commit 38447ca3ee
2 changed files with 23 additions and 1 deletions

View File

@ -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);

View File

@ -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>