svn commit: r1734269 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

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

svn commit: r1734269 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

jleroux@apache.org
Author: jleroux
Date: Wed Mar  9 15:36:56 2016
New Revision: 1734269

URL: http://svn.apache.org/viewvc?rev=1734269&view=rev
Log:
A patch from Forrest Rae for "GroovyEngine.serviceInvoker masks Groovy script exceptions in some cases" https://issues.apache.org/jira/browse/OFBIZ-6888

If GroovyEngine.serviceInvoker catches an exception in a Groovy script, it would mask the exception in some cases.  An exception's detailMessage can be null.  If it is null, the exception won't be properly returned and logged, and that will make spotting problems very difficult.  This was the case for me while trying to track down a problem with a java.util.ConcurrentModificationException error in a Groovy script.  I suspect that this choice to mask exceptions and only return the message has cause bugs to not be spotted.

Disabling this for now in favor of returning a proper exception.  GroovyEngine.serviceInvoker() should throw GenericServiceException if error, rather than returning ServiceUtil.returnError(e.getMessage())


Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java?rev=1734269&r1=1734268&r2=1734269&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java Wed Mar  9 15:36:56 2016
@@ -121,7 +121,10 @@ public final class GroovyEngine extends
         } catch (GeneralException ge) {
             throw new GenericServiceException(ge);
         } catch (Exception e) {
-            return ServiceUtil.returnError(e.getMessage());
+            // detailMessage can be null.  If it is null, the exception won't be properly returned and logged, and that will
+            // make spotting problems very difficult.  Disabling this for now in favor of returning a proper exception.
+            // return ServiceUtil.returnError(e.getMessage());
+            throw new GenericServiceException("Error running Groovy method [" + modelService.invoke + "] in Groovy file [" + modelService.location + "]: ", e);
         }
     }
 }