[jboss-svn-commits] JBL Code SVN: r29333 - labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 14 09:27:51 EDT 2009


Author: kevin.conner at jboss.com
Date: 2009-09-14 09:27:50 -0400 (Mon, 14 Sep 2009)
New Revision: 29333

Added:
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/JobUtil.java
Modified:
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteJobCommand.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteTimerCommand.java
Log:
Fix handling of deleted jobs/timers: JBESB-2820

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteJobCommand.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteJobCommand.java	2009-09-14 12:00:44 UTC (rev 29332)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteJobCommand.java	2009-09-14 13:27:50 UTC (rev 29333)
@@ -72,7 +72,7 @@
   public Object execute(JbpmContext jbpmContext) throws Exception {
     JobSession jobSession = jbpmContext.getJobSession();
     Job job = jobSession.getJob(jobId);
-    if (job == null) {
+    if (JobUtil.isDeleted(job)) {
       if (log.isDebugEnabled()) {
         log.debug("job " + jobId + " was deleted");
       }

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteTimerCommand.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteTimerCommand.java	2009-09-14 12:00:44 UTC (rev 29332)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/ExecuteTimerCommand.java	2009-09-14 13:27:50 UTC (rev 29333)
@@ -58,6 +58,12 @@
      */
     public Object execute(JbpmContext jbpmContext) throws Exception {
       Timer timer = jbpmContext.getJobSession().loadTimer(timerId);
+      if (JobUtil.isDeleted(timer)) {
+        if (log.isDebugEnabled()) {
+          log.debug("timer " + timerId + " was deleted");
+        }
+        return null;
+      }
       if (timer.isSuspended()) {
         if (log.isDebugEnabled()) {
           log.debug(timer + " is suspended");

Copied: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/JobUtil.java (from rev 29273, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/JobUtil.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/JobUtil.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/job/JobUtil.java	2009-09-14 13:27:50 UTC (rev 29333)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.services.jbpm.integration.job;
+
+import org.jbpm.job.Job;
+
+/**
+ * Job utility methods used by the commands.
+ * @author Kevin Conner
+ */
+class JobUtil
+{
+    /**
+     * Has the job been deleted?
+     * @param job The job to test.
+     * @return true if deleted, false otherwise.
+     */
+    static boolean isDeleted(final Job job)
+    {
+        /*
+         * The jBPM code tests for null but lazy loading means
+         * that a proxy is returned and that an exception will be
+         * raised when accessed.  We test for both assumptions here,
+         * just to be safe.
+         */
+        if (job != null)
+        {
+            try
+            {
+                job.getLockOwner() ;
+                return false ;
+            }
+            catch (final Exception ex) {} // ignore
+        }
+        return true ;
+    }
+}



More information about the jboss-svn-commits mailing list