Author: mbrohl
Date: Sun Oct 22 13:31:23 2017 New Revision: 1812916 URL: http://svn.apache.org/viewvc?rev=1812916&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.service.job. (OFBIZ-9709) Thanks Dennis Balkir for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/AbstractJob.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/JobManager.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/AbstractJob.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/AbstractJob.java?rev=1812916&r1=1812915&r2=1812916&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/AbstractJob.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/AbstractJob.java Sun Oct 22 13:31:23 2017 @@ -113,6 +113,6 @@ public abstract class AbstractJob implem @Override public Date getStartTime() { - return startTime; + return (Date) startTime.clone(); } } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/JobManager.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/JobManager.java?rev=1812916&r1=1812915&r2=1812916&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/JobManager.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/JobManager.java Sun Oct 22 13:31:23 2017 @@ -71,7 +71,7 @@ public final class JobManager { public static final String module = JobManager.class.getName(); public static final String instanceId = UtilProperties.getPropertyValue("general", "unique.instanceId", "ofbiz0"); - private static final ConcurrentHashMap<String, JobManager> registeredManagers = new ConcurrentHashMap<String, JobManager>(); + private static final ConcurrentHashMap<String, JobManager> registeredManagers = new ConcurrentHashMap<>(); private static boolean isShutDown = false; private static void assertIsRunning() { @@ -160,7 +160,7 @@ public final class JobManager { private static List<String> getRunPools() throws GenericConfigException { List<RunFromPool> runFromPools = ServiceConfigUtil.getServiceEngine().getThreadPool().getRunFromPools(); - List<String> readPools = new ArrayList<String>(runFromPools.size()); + List<String> readPools = new ArrayList<>(runFromPools.size()); for (RunFromPool runFromPool : runFromPools) { readPools.add(runFromPool.getName()); } @@ -201,7 +201,7 @@ public final class JobManager { poolsExpr.add(EntityCondition.makeCondition("poolId", EntityOperator.EQUALS, poolName)); } } - List<Job> poll = new ArrayList<Job>(limit); + List<Job> poll = new ArrayList<>(limit); // make the conditions EntityCondition baseCondition = EntityCondition.makeCondition(expressions); EntityCondition poolCondition = EntityCondition.makeCondition(poolsExpr, EntityOperator.OR); @@ -492,12 +492,8 @@ public final class JobManager { runtimeData.set("runtimeInfo", XmlSerializer.serialize(context)); runtimeData = delegator.createSetNextSeqId(runtimeData); dataId = runtimeData.getString("runtimeDataId"); - } catch (GenericEntityException ee) { - throw new JobManagerException(ee.getMessage(), ee); - } catch (SerializeException se) { - throw new JobManagerException(se.getMessage(), se); - } catch (IOException ioe) { - throw new JobManagerException(ioe.getMessage(), ioe); + } catch (GenericEntityException | SerializeException | IOException e) { + throw new JobManagerException(e.getMessage(), e); } // schedule the job schedule(jobName, poolName, serviceName, dataId, startTime, frequency, interval, count, endTime, maxRetry); @@ -561,7 +557,7 @@ public final class JobManager { jFields.put("loaderName", delegator.getDelegatorName()); // set the max retry jFields.put("maxRetry", Long.valueOf(maxRetry)); - jFields.put("currentRetryCount", new Long(0)); + jFields.put("currentRetryCount", Long.valueOf(0)); // create the value and store GenericValue jobV; try { Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java?rev=1812916&r1=1812915&r2=1812916&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java Sun Oct 22 13:31:23 2017 @@ -106,16 +106,15 @@ public class PersistedServiceJob extends if (cancelTime != null || startTime != null) { // job not available throw new InvalidJobException("Job [" + getJobId() + "] is not available"); - } else { - jobValue.set("statusId", "SERVICE_QUEUED"); - try { - jobValue.store(); - } catch (GenericEntityException e) { - throw new InvalidJobException("Unable to set the startDateTime and statusId on the current job [" + getJobId() + "]; not running!", e); - } - if (Debug.verboseOn()) { - Debug.logVerbose("Placing job [" + getJobId() + "] in queue", module); - } + } + jobValue.set("statusId", "SERVICE_QUEUED"); + try { + jobValue.store(); + } catch (GenericEntityException e) { + throw new InvalidJobException("Unable to set the startDateTime and statusId on the current job [" + getJobId() + "]; not running!", e); + } + if (Debug.verboseOn()) { + Debug.logVerbose("Placing job [" + getJobId() + "] in queue", module); } } @@ -203,9 +202,9 @@ public class PersistedServiceJob extends newJob.set("runByInstanceId", null); newJob.set("runTime", new java.sql.Timestamp(next)); if (isRetryOnFailure) { - newJob.set("currentRetryCount", new Long(currentRetryCount + 1)); + newJob.set("currentRetryCount", Long.valueOf(currentRetryCount + 1)); } else { - newJob.set("currentRetryCount", new Long(0)); + newJob.set("currentRetryCount", Long.valueOf(0)); } nextRecurrence = next; delegator.createSetNextSeqId(newJob); @@ -289,7 +288,7 @@ public class PersistedServiceJob extends } } if (context == null) { - context = new HashMap<String, Object>(); + context = new HashMap<>(); } // check the runAsUser if (UtilValidate.isNotEmpty(jobValue.getString("runAsUser"))) { |
Free forum by Nabble | Edit this page |