svn commit: r1804962 - /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java

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

svn commit: r1804962 - /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java

jleroux@apache.org
Author: jleroux
Date: Mon Aug 14 09:47:36 2017
New Revision: 1804962

URL: http://svn.apache.org/viewvc?rev=1804962&view=rev
Log:
Improved: GenericServiceJob.failed(Throwable) avoid logging stacktraces for
non technical service semaphore exceptions
(OFBIZ-9400)

GenericServicejob.failed(...) logs a stacktrace on every SemaphoreWait and
SemaphoreFail exception. The patch changes this for the non-technical service
semaphore exceptions to a one liner error logging to avoid polluting the logfile
with stacktraces e.g. in a scenario where a service is scheduled in short
intervals and fails expected while the former one is still running.

jleroux: I agree the case Martin describes must be quite annoying, especially in
production!

Thanks: Martin Becker

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java?rev=1804962&r1=1804961&r2=1804962&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/GenericServiceJob.java Mon Aug 14 09:47:36 2017
@@ -27,7 +27,8 @@ import org.apache.ofbiz.service.Dispatch
 import org.apache.ofbiz.service.GenericRequester;
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ServiceUtil;
-
+import org.apache.ofbiz.service.semaphore.SemaphoreFailException;
+import org.apache.ofbiz.service.semaphore.SemaphoreWaitException;
 /**
  * A generic async-service job.
  */
@@ -111,11 +112,12 @@ public class GenericServiceJob extends A
      * @param t Throwable
      */
     protected void failed(Throwable t) throws InvalidJobException {
-        if (currentState != State.RUNNING) {
-            throw new InvalidJobException("Illegal state change");
+        if (t instanceof SemaphoreWaitException || t instanceof SemaphoreFailException) {
+            Debug.logError("Async-Service failed due to " + t, module);
+        } else {
+            Debug.logError(t, "Async-Service failed.", module);
         }
         currentState = State.FAILED;
-        Debug.logError(t, "Async-Service failed.", module);
     }
 
     /**