在我的junit 4测试代码中,我正在使用包含如下代码的测试规则:
catch (Throwable t) {
t.printStackTrace();
throw t;
}
Run Code Online (Sandbox Code Playgroud)
Findbugs对此有所抱怨,这是正确的-我们的生产代码中不应这样做。但是,在这种情况下,我认为用法是合理的,我尝试使用@SuppressFBWarnings注释使findbugs静音。但是,两者都没有
@SuppressFBWarnings
private void warmUp() throws Throwable {
Run Code Online (Sandbox Code Playgroud)
也不
@SuppressFBWarnings("IMC_IMMATURE_CLASS_PRINTSTACKTRACE")
private void warmUp() throws Throwable {
Run Code Online (Sandbox Code Playgroud)
也不
@SuppressFBWarnings({"IMC_IMMATURE_CLASS_PRINTSTACKTRACE"})
private void warmUp() throws Throwable {
Run Code Online (Sandbox Code Playgroud)
有理想的结果。
如何正确使用@SuppressFBWarnings取消警告?