Add try-catch to parse #125
Open
ci.jenkins.io / SpotBugs
failed
Dec 14, 2023 in 0s
2 new issues
Total | New | Outstanding | Fixed | Trend |
---|---|---|---|---|
2 | 2 | 0 | 0 | 👎 |
Reference build: Plugins » accurev-plugin » master #118
Details
Severity distribution of new issues
Error | Warning High | Warning Normal | Warning Low |
---|---|---|---|
0 | 0 | 1 | 1 |
Annotations
Check warning on line 313 in src/main/java/hudson/plugins/accurev/ParseChangeLog.java
ci-jenkins-io / SpotBugs
REC_CATCH_EXCEPTION
NORMAL:
Exception is caught when Exception is not thrown in hudson.plugins.accurev.ParseChangeLog.parseTransactions(XmlPullParser, File, ParseChangeLog$UpdateLog)
Raw output
<p> This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs. </p> <p>A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p> <pre><code>try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... } </code></pre>
Check warning on line 313 in src/main/java/hudson/plugins/accurev/ParseChangeLog.java
ci-jenkins-io / SpotBugs
REC_CATCH_EXCEPTION
LOW:
Exception is caught when Exception is not thrown in hudson.plugins.accurev.ParseChangeLog.parseTransactions(XmlPullParser, File, ParseChangeLog$UpdateLog)
Raw output
<p> This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs. </p> <p>A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p> <pre><code>try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... } </code></pre>
Loading