You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Julian Leichert (JIRA)" <ji...@apache.org> on 2017/09/07 12:56:00 UTC
[jira] [Updated] (OFBIZ-9685) [FB] Package
org.apache.ofbiz.widget.renderer.fo
[ https://issues.apache.org/jira/browse/OFBIZ-9685?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Leichert updated OFBIZ-9685:
-----------------------------------
Attachment: OFBIZ-9685_org.apache.ofbiz.widget.renderer.fo_bugfixes.patch
Added Multi-catches
> [FB] Package org.apache.ofbiz.widget.renderer.fo
> ------------------------------------------------
>
> Key: OFBIZ-9685
> URL: https://issues.apache.org/jira/browse/OFBIZ-9685
> Project: OFBiz
> Issue Type: Sub-task
> Components: ALL APPLICATIONS, ALL COMPONENTS
> Affects Versions: Trunk
> Reporter: Julian Leichert
> Priority: Minor
> Attachments: OFBIZ-9685_org.apache.ofbiz.widget.renderer.fo_bugfixes.patch
>
>
> ScreenFopViewHandler.java:93, REC_CATCH_EXCEPTION
> - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.widget.renderer.fo.ScreenFopViewHandler.render(String, String, String, String, String, HttpServletRequest, HttpServletResponse)
> 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.
> 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:
> try {
> ...
> } catch (RuntimeException e) {
> throw e;
> } catch (Exception e) {
> ... deal with all non-runtime exceptions ...
> }
> ScreenFopViewHandler.java:193, REC_CATCH_EXCEPTION
> - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.widget.renderer.fo.ScreenFopViewHandler.renderError(String, Exception, String, HttpServletRequest, HttpServletResponse)
> 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.
> 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:
> try {
> ...
> } catch (RuntimeException e) {
> throw e;
> } catch (Exception e) {
> ... deal with all non-runtime exceptions ...
> }
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)