[jira] [Closed] (OFBIZ-8341) Fix Default or Empty Catch block in Java files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Closed] (OFBIZ-8341) Fix Default or Empty Catch block in Java files

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-8341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux closed OFBIZ-8341.
----------------------------------
    Resolution: Fixed

After my last commits this morning, I checked if there were still swallowed exceptions, using the regexp below (note the white space ahead)
{code}
 +\} catch \(.*\) \{\R\R +\}\R
{code}
and some variations, like
{code}
 +\} catch \(.*\) \{\R +\R +\}\R
 +\} catch \(.*\) \{\R\R +\}\R
{code}
And found only 3 PatternSyntaxException which are from pre Apache era and seems OK because it's always the same pattern
{code}
                        try {
                            String queryStringEncoded = queryString.replaceAll("&", "%26");
                            context.put("queryStringEncoded", queryStringEncoded);
                        } catch (PatternSyntaxException e) {

{code}
and obviously a PatternSyntaxException should not occur there. So they simply miss a comment to document the fact even it it seems obvious. I put it at revision: 1789163  
I note though that the repeated pattern is a smell for refactoring...

I also begin to have a look into the ebaystore component which is a can of worms when you look at its exception handling. But, according to my research, there are no longer swallowed exceptions.

> Fix Default or Empty Catch block in Java files
> ----------------------------------------------
>
>                 Key: OFBIZ-8341
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-8341
>             Project: OFBiz
>          Issue Type: Bug
>          Components: ALL COMPONENTS
>            Reporter: Harsh Vijaywargiya
>            Assignee: Jacques Le Roux
>             Fix For: Upcoming Release
>
>
> In many Java files we have auto generated catch blocks or empty catch blocks.
> To avoid such exception swallowing this should be improved to at least log the error and also return error in case of service.
> As of now I found following classes with such patterns -
> InventoryServices.java
> FreeMarkerWorker.java
> QRCodeEvents.java
> QRCodeServices.java



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)