rewrite-static-analysis
rewrite-static-analysis copied to clipboard
org.openrewrite.staticanalysis.UnnecessaryThrows failing to detect thrown exception
What version of OpenRewrite are you using?
I am using 6.6.3
How are you running OpenRewrite?
What is the smallest, simplest way to reproduce the problem?
import com.fasterxml.jackson.core.JsonProcessingException;
public class PlacementConfig
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
public Map<String, Object> asMap() throws JsonProcessingException
{
return OBJECT_MAPPER.treeToValue(OBJECT_MAPPER.valueToTree(this.getAllConfigs()), Map.class);
}
}
What did you expect to see?
Unchaged
What did you see instead?
public class PlacementConfig
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
public Map<String, Object> asMap()
{
return OBJECT_MAPPER.treeToValue(OBJECT_MAPPER.valueToTree(this.getAllConfigs()), Map.class);
}
}
Blows up with
/workplace/mnr/InsistorRedux/src/JavelinRenderingService/src/com/amazon/javelinrenderingservice/cache/model/PlacementConfig.java:147: error: unreported exception JsonProcessingException; must be caught or declared to be thrown
return OBJECT_MAPPER.treeToValue(OBJECT_MAPPER.valueToTree(this.getAllConfigs()), Map.class);
Some how https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/java/org/openrewrite/staticanalysis/UnnecessaryThrows.java#L106 is not filtering?
Are you interested in [contributing a fix to OpenRewrite]
Yes