[jbpm-commits] JBoss JBPM SVN: r6857 - jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 1 23:35:33 EST 2010


Author: alex.guizar at jboss.com
Date: 2010-12-01 23:35:32 -0500 (Wed, 01 Dec 2010)
New Revision: 6857

Modified:
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
Log:
initialize local variables in various JobExecutorThread and DispatcherThread methods to work around bug in jdk 1.4 bytecode verifier;
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4381996

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java	2010-12-02 01:48:28 UTC (rev 6856)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java	2010-12-02 04:35:32 UTC (rev 6857)
@@ -98,33 +98,34 @@
   }
 
   private Job acquireJob() {
+    Job job = null;
     boolean debug = log.isDebugEnabled();
-    Job job;
     // acquire job executor's monitor before creating context and allocating resources
     synchronized (jobExecutor) {
       JbpmContext jbpmContext = jobExecutor.getJbpmConfiguration().createJbpmContext();
       try {
         // look for available job
-        job = jbpmContext.getJobSession().getFirstAcquirableJob(null);
+        Job firstJob = jbpmContext.getJobSession().getFirstAcquirableJob(null);
         // is there a job?
-        if (job != null) {
+        if (firstJob != null) {
           // lock job
-          job.setLockOwner(getName());
-          job.setLockTime(new Date());
+          firstJob.setLockOwner(getName());
+          firstJob.setLockTime(new Date());
           // has job failed previously?
-          if (job.getException() != null) {
+          if (firstJob.getException() != null) {
             // decrease retry count
-            int retries = job.getRetries() - 1;
-            job.setRetries(retries);
+            int retries = firstJob.getRetries() - 1;
+            firstJob.setRetries(retries);
             if (debug) log.debug(job + " has " + retries + " retries remaining");
           }
-          if (debug) log.debug("acquired " + job);
+          // deliver result
+          if (debug) log.debug("acquired " + firstJob);
+          job = firstJob;
         }
         else if (debug) log.debug("no acquirable job found");
       }
       catch (RuntimeException e) {
         jbpmContext.setRollbackOnly();
-        job = null;
         if (debug) log.debug("failed to acquire job", e);
       }
       catch (Error e) {
@@ -194,21 +195,17 @@
   }
 
   private Date getNextDueDate() {
-    Date nextDueDate;
+    Date nextDueDate = null;
     JbpmContext jbpmContext = jobExecutor.getJbpmConfiguration().createJbpmContext();
     try {
       Job job = jbpmContext.getJobSession().getFirstDueJob(null, null);
       if (job != null) {
         nextDueDate = job.getDueDate();
       }
-      else {
-        nextDueDate = null;
-        if (log.isDebugEnabled()) log.debug("no due job found");
-      }
+      else if (log.isDebugEnabled()) log.debug("no due job found");
     }
     catch (RuntimeException e) {
       jbpmContext.setRollbackOnly();
-      nextDueDate = null;
       if (log.isDebugEnabled()) log.debug("failed to determine next due date", e);
     }
     catch (Error e) {

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2010-12-02 01:48:28 UTC (rev 6856)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2010-12-02 04:35:32 UTC (rev 6857)
@@ -6,6 +6,7 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -65,7 +66,7 @@
 
   /** @deprecated call {@link #acquireJob()} instead **/
   protected Collection acquireJobs() {
-    Collection jobs;
+    Collection jobs = Collections.EMPTY_LIST;
     boolean debug = log.isDebugEnabled();
     JbpmContext jbpmContext = jobExecutor.getJbpmConfiguration().createJbpmContext();
     try {
@@ -79,33 +80,35 @@
         if (firstJob.isExclusive()) {
           // find other exclusive jobs
           ProcessInstance processInstance = firstJob.getProcessInstance();
-          jobs = jobSession.findExclusiveJobs(lockOwner, processInstance);
-          if (debug) log.debug("acquiring exclusive " + jobs + " for " + processInstance);
+          List exclusiveJobs = jobSession.findExclusiveJobs(lockOwner, processInstance);
+
+          if (debug) log.debug("acquiring " + exclusiveJobs + " for " + processInstance);
+          Date lockTime = new Date();
+          for (Iterator i = exclusiveJobs.iterator(); i.hasNext();) {
+            Job job = (Job) i.next();
+            job.setLockOwner(lockOwner);
+            job.setLockTime(lockTime);
+          }
+
+          // deliver result
+          if (debug) log.debug("acquired " + exclusiveJobs);
+          jobs = exclusiveJobs;
         }
         else {
-          jobs = Collections.singletonList(firstJob);
           if (debug) log.debug("acquiring " + firstJob);
-        }
+          firstJob.setLockOwner(lockOwner);
+          firstJob.setLockTime(new Date());
 
-        // acquire jobs
-        Date lockTime = new Date();
-        for (Iterator i = jobs.iterator(); i.hasNext();) {
-          // lock job
-          Job job = (Job) i.next();
-          job.setLockOwner(lockOwner);
-          job.setLockTime(lockTime);
+          // deliver result
+          if (debug) log.debug("acquired " + firstJob);
+          jobs = Collections.singletonList(firstJob);
         }
-        if (debug) log.debug("acquired " + jobs);
       }
-      else {
-        jobs = Collections.EMPTY_LIST;
-        if (debug) log.debug("no acquirable job found");
-      }
+      else if (debug) log.debug("no acquirable job found");
     }
     catch (RuntimeException e) {
       jbpmContext.setRollbackOnly();
       if (debug) log.debug("failed to acquire jobs", e);
-      jobs = Collections.EMPTY_LIST;
     }
     catch (Error e) {
       jbpmContext.setRollbackOnly();
@@ -257,7 +260,7 @@
 
   /** @deprecated moved to {@link DispatcherThread} */
   protected Date getNextDueDate() {
-    Date nextDueDate;
+    Date nextDueDate = null;
     JbpmContext jbpmContext = jobExecutor.getJbpmConfiguration().createJbpmContext();
     try {
       String lockOwner = getName();
@@ -267,14 +270,10 @@
         jobExecutor.addMonitoredJobId(lockOwner, job.getId());
         nextDueDate = job.getDueDate();
       }
-      else {
-        nextDueDate = null;
-        if (log.isDebugEnabled()) log.debug("no due job found");
-      }
+      else if (log.isDebugEnabled()) log.debug("no due job found");
     }
     catch (RuntimeException e) {
       jbpmContext.setRollbackOnly();
-      nextDueDate = null;
       if (log.isDebugEnabled()) log.debug("failed to determine next due date", e);
     }
     catch (Error e) {



More information about the jbpm-commits mailing list