Author: adrianc
Date: Sat Aug 4 22:06:24 2012
New Revision: 1369485
URL:
http://svn.apache.org/viewvc?rev=1369485&view=revLog:
Fixed a bug in GenericServiceJob where the failed method would get called twice.
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java?rev=1369485&r1=1369484&r2=1369485&view=diff==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java Sat Aug 4 22:06:24 2012
@@ -27,7 +27,6 @@ import org.ofbiz.service.DispatchContext
import org.ofbiz.service.GenericRequester;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
-import org.ofbiz.service.job.Job.State;
/**
* Generic Service Job - A generic async-service Job.
@@ -62,35 +61,32 @@ public class GenericServiceJob extends A
}
currentState = State.RUNNING;
init();
-
+ Throwable thrown = null;
Map<String, Object> result = null;
// no transaction is necessary since runSync handles this
try {
// get the dispatcher and invoke the service via runSync -- will run all ECAs
LocalDispatcher dispatcher = dctx.getDispatcher();
result = dispatcher.runSync(getServiceName(), getContext());
-
// check for a failure
if (ServiceUtil.isError(result)) {
- this.failed(new Exception(ServiceUtil.getErrorMessage(result)));
+ thrown = new Exception(ServiceUtil.getErrorMessage(result));
}
-
if (requester != null) {
requester.receiveResult(result);
}
-
} catch (Throwable t) {
- // pass the exception back to the requester.
if (requester != null) {
+ // pass the exception back to the requester.
requester.receiveThrowable(t);
}
-
- // call the failed method
- this.failed(t);
+ thrown = t;
+ }
+ if (thrown == null) {
+ finish(result);
+ } else {
+ failed(thrown);
}
-
- // call the finish method
- this.finish(result);
}
/**