[ https://issues.apache.org/jira/browse/MPMD-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956772#comment-17956772 ]
ASF GitHub Bot commented on MPMD-412: ------------------------------------- pzygielo commented on code in PR #226: URL: https://github.com/apache/maven-pmd-plugin/pull/226#discussion_r2134618260 ########## src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java: ########## @@ -40,35 +41,26 @@ public class CustomConfigurationMavenProjectStub extends PmdProjectStub { private List<ReportPlugin> reportPlugins = new ArrayList<>(); - public CustomConfigurationMavenProjectStub() { + public CustomConfigurationMavenProjectStub() throws IOException, XmlPullParserException { MavenXpp3Reader pomReader = new MavenXpp3Reader(); - Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { - model = pomReader.read(is); - setModel(model); - } catch (Exception e) { - } + InputStream in = new FileInputStream(getBasedir() + "/" + getPOM()); Review Comment: If I auto-close this renamed `in` here, with try-with-resources, no test fails on me: ``` Tests run: 50, Failures: 0, Errors: 0, Skipped: 0 ``` How to see the failure _when the `pomReader` closes the inputstream_? In which test? When `pomReader` does that? > Tests are inobviously broken due to overly broad catch clauses > -------------------------------------------------------------- > > Key: MPMD-412 > URL: https://issues.apache.org/jira/browse/MPMD-412 > Project: Maven PMD Plugin (Moved to GitHub Issues) > Issue Type: Bug > Reporter: Elliotte Rusty Harold > Priority: Blocker > > See https://github.com/apache/maven-pmd-plugin/pull/178 > We're catching java.lang.Exception and thus often missing that the wrong > exception is being caught, and that the test is in fact failing. -- This message was sent by Atlassian Jira (v8.20.10#820010)