You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/09/03 19:27:49 UTC

svn commit: r1807162 - in /ofbiz/ofbiz-framework/trunk: applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java framework/webtools/groovyScripts/stats/StatBinsHistory.groovy

Author: jleroux
Date: Sun Sep  3 19:27:49 2017
New Revision: 1807162

URL: http://svn.apache.org/viewvc?rev=1807162&view=rev
Log:
Fixed: Fix Default or Empty Catch block in Java and Groovy files
(OFBIZ-8341)

In many Java and Groovy 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.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java
    ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/stats/StatBinsHistory.groovy

Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java?rev=1807162&r1=1807161&r2=1807162&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java Sun Sep  3 19:27:49 2017
@@ -440,7 +440,18 @@ public class UploadContentAndImage {
                 Long sequenceNum = null;
                 try {
                     sequenceNum = Long.valueOf((String)objSequenceNum);
-                } catch (NumberFormatException e) {}
+                } catch (NumberFormatException e) {
+                    String msg = "Caught an exception : " + e.toString();
+                    Debug.logError(e, msg);
+                    request.setAttribute("_ERROR_MESSAGE_", msg);
+                    List<String> errorMsgList = UtilGenerics.checkList(request.getAttribute("_EVENT_MESSAGE_LIST_"));
+                    if (errorMsgList == null) {
+                        errorMsgList = new LinkedList<String>();
+                        request.setAttribute("errorMessageList", errorMsgList);
+                    }
+                    errorMsgList.add(msg);
+                    return "error";
+                }
                 passedParams.put("caSequenceNum", sequenceNum);
             }
         }

Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/stats/StatBinsHistory.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/stats/StatBinsHistory.groovy?rev=1807162&r1=1807161&r2=1807162&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/stats/StatBinsHistory.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/stats/StatBinsHistory.groovy Sun Sep  3 19:27:49 2017
@@ -26,7 +26,10 @@ typeStr = parameters.type
 type = -1
 try {
     type = Integer.valueOf(typeStr)
-} catch (NumberFormatException e) {}
+} catch (NumberFormatException nfe) {
+    Debug.logError(nfe, "Caught an exception : " + nfe.toString(), "StatBinsHistory.groovy")
+    errMsgList.add("Entered value is non-numeric for numeric field: " + field.getName())
+}
 
 binList = null
 if (type == ServerHitBin.REQUEST) {