From 6b474d6b4f9651644b0bb6974db8c5b422c9c2e0 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 7 Nov 2024 22:43:00 +0100 Subject: [PATCH] refactor: remove-redundant-initialization Signed-off-by: Carlos Garcia --- .../java/org/quartz/core/JobRunShell.java | 10 ++++---- .../java/org/quartz/core/QuartzScheduler.java | 14 +++++------ .../quartz/core/QuartzSchedulerThread.java | 4 ++-- .../org/quartz/core/jmx/TriggerSupport.java | 4 ++-- .../quartz/impl/JobExecutionContextImpl.java | 2 +- .../org/quartz/impl/StdSchedulerFactory.java | 24 +++++++++---------- .../impl/jdbcjobstore/HSQLDBDelegate.java | 2 +- .../quartz/impl/jdbcjobstore/JobStoreCMT.java | 2 +- .../impl/jdbcjobstore/MSSQLDelegate.java | 2 +- .../impl/jdbcjobstore/PointbaseDelegate.java | 8 +++---- .../impl/jdbcjobstore/PostgreSQLDelegate.java | 4 ++-- .../impl/jdbcjobstore/SybaseDelegate.java | 2 +- .../jdbcjobstore/oracle/OracleDelegate.java | 8 +++---- .../DailyTimeIntervalTriggerImpl.java | 2 +- .../history/LoggingJobHistoryPlugin.java | 2 +- .../org/quartz/plugins/xml/FileScanJob.java | 2 +- .../org/quartz/simpl/SimpleThreadPool.java | 2 +- .../quartz/utils/JNDIConnectionProvider.java | 2 +- .../org/quartz/utils/PropertiesParser.java | 2 +- .../xml/XMLSchedulingDataProcessor.java | 2 +- 20 files changed, 50 insertions(+), 50 deletions(-) diff --git a/quartz/src/main/java/org/quartz/core/JobRunShell.java b/quartz/src/main/java/org/quartz/core/JobRunShell.java index 8d9d9a65d..255af1a28 100644 --- a/quartz/src/main/java/org/quartz/core/JobRunShell.java +++ b/quartz/src/main/java/org/quartz/core/JobRunShell.java @@ -69,9 +69,9 @@ public class JobRunShell extends SchedulerListenerSupport implements Runnable { protected QuartzScheduler qs = null; - protected TriggerFiredBundle firedTriggerBundle = null; + protected TriggerFiredBundle firedTriggerBundle; - protected Scheduler scheduler = null; + protected Scheduler scheduler; protected volatile boolean shutdownRequested = false; @@ -121,7 +121,7 @@ public void initialize(QuartzScheduler sched) throws SchedulerException { this.qs = sched; - Job job = null; + Job job; JobDetail jobDetail = firedTriggerBundle.getJobDetail(); try { @@ -195,7 +195,7 @@ public void run() { } long startTime = System.currentTimeMillis(); - long endTime = startTime; + long endTime; // execute the job try { @@ -287,7 +287,7 @@ public void passivate() { private boolean notifyListenersBeginning(JobExecutionContext jobExCtx) throws VetoedException { - boolean vetoed = false; + boolean vetoed; // notify all trigger listeners try { diff --git a/quartz/src/main/java/org/quartz/core/QuartzScheduler.java b/quartz/src/main/java/org/quartz/core/QuartzScheduler.java index 0a1a98144..ba508d0fa 100644 --- a/quartz/src/main/java/org/quartz/core/QuartzScheduler.java +++ b/quartz/src/main/java/org/quartz/core/QuartzScheduler.java @@ -360,7 +360,7 @@ private void bind() throws RemoteException { return; } - RemotableQuartzScheduler exportable = null; + RemotableQuartzScheduler exportable; if(resources.getRMIServerPort() > 0) { exportable = (RemotableQuartzScheduler) UnicastRemoteObject @@ -370,7 +370,7 @@ private void bind() throws RemoteException { .exportObject(this, 1099); } - Registry registry = null; + Registry registry; if (resources.getRMICreateRegistryStrategy().equals( QuartzSchedulerResources.CREATE_REGISTRY_AS_NEEDED)) { @@ -965,7 +965,7 @@ public boolean deleteJob(JobKey jobKey) throws SchedulerException { public boolean deleteJobs(List jobKeys) throws SchedulerException { validateState(); - boolean result = false; + boolean result; result = resources.getJobStore().removeJobs(jobKeys); notifySchedulerThread(0L); @@ -1030,7 +1030,7 @@ public void scheduleJob(JobDetail jobDetail, Set triggersForJ public boolean unscheduleJobs(List triggerKeys) throws SchedulerException { validateState(); - boolean result = false; + boolean result; result = resources.getJobStore().removeTriggers(triggerKeys); notifySchedulerThread(0L); @@ -2263,8 +2263,8 @@ public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException { List jobs = getCurrentlyExecutingJobs(); - JobDetail jobDetail = null; - Job job = null; + JobDetail jobDetail; + Job job; boolean interrupted = false; @@ -2301,7 +2301,7 @@ public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException { public boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException { List jobs = getCurrentlyExecutingJobs(); - Job job = null; + Job job; for(JobExecutionContext jec : jobs) { if (jec.getFireInstanceId().equals(fireInstanceId)) { diff --git a/quartz/src/main/java/org/quartz/core/QuartzSchedulerThread.java b/quartz/src/main/java/org/quartz/core/QuartzSchedulerThread.java index c31427edd..640c2ad61 100644 --- a/quartz/src/main/java/org/quartz/core/QuartzSchedulerThread.java +++ b/quartz/src/main/java/org/quartz/core/QuartzSchedulerThread.java @@ -355,7 +355,7 @@ public void run() { // set triggers to 'executing' List bundles = new ArrayList<>(); - boolean goAhead = true; + boolean goAhead; synchronized(sigLock) { goAhead = !halted.get(); } @@ -397,7 +397,7 @@ public void run() { continue; } - JobRunShell shell = null; + JobRunShell shell; try { shell = qsRsrcs.getJobRunShellFactory().createJobRunShell(bundle); shell.initialize(qs); diff --git a/quartz/src/main/java/org/quartz/core/jmx/TriggerSupport.java b/quartz/src/main/java/org/quartz/core/jmx/TriggerSupport.java index 23cff5522..60f93ea15 100644 --- a/quartz/src/main/java/org/quartz/core/jmx/TriggerSupport.java +++ b/quartz/src/main/java/org/quartz/core/jmx/TriggerSupport.java @@ -171,7 +171,7 @@ public static void initializeTrigger(MutableTrigger trigger, Map } public static OperableTrigger newTrigger(CompositeData cData) throws ParseException { - OperableTrigger result = null; + OperableTrigger result; if(cData.containsKey("cronExpression")) { result = CronTriggerSupport.newTrigger(cData); } else { @@ -181,7 +181,7 @@ public static OperableTrigger newTrigger(CompositeData cData) throws ParseExcept } public static OperableTrigger newTrigger(Map attrMap) throws ParseException { - OperableTrigger result = null; + OperableTrigger result; if(attrMap.containsKey("cronExpression")) { result = CronTriggerSupport.newTrigger(attrMap); } else { diff --git a/quartz/src/main/java/org/quartz/impl/JobExecutionContextImpl.java b/quartz/src/main/java/org/quartz/impl/JobExecutionContextImpl.java index 9c19eb5de..a10b36b4b 100644 --- a/quartz/src/main/java/org/quartz/impl/JobExecutionContextImpl.java +++ b/quartz/src/main/java/org/quartz/impl/JobExecutionContextImpl.java @@ -58,7 +58,7 @@ public class JobExecutionContextImpl implements java.io.Serializable, JobExecuti private final Calendar calendar; - private boolean recovering = false; + private boolean recovering; private int numRefires = 0; diff --git a/quartz/src/main/java/org/quartz/impl/StdSchedulerFactory.java b/quartz/src/main/java/org/quartz/impl/StdSchedulerFactory.java index ef7be53fb..a0923fef0 100644 --- a/quartz/src/main/java/org/quartz/impl/StdSchedulerFactory.java +++ b/quartz/src/main/java/org/quartz/impl/StdSchedulerFactory.java @@ -528,7 +528,7 @@ public void initialize(String filename) throws SchedulerException { throw initException; } - InputStream is = null; + InputStream is; Properties props = new Properties(); is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename); @@ -616,12 +616,12 @@ private Scheduler instantiate() throws SchedulerException { throw initException; } - JobStore js = null; - ThreadPool tp = null; + JobStore js; + ThreadPool tp; QuartzScheduler qs = null; DBConnectionManager dbMgr = null; String instanceIdGeneratorClass = null; - Properties tProps = null; + Properties tProps; String userTXLocation = null; boolean wrapJobInTx = false; boolean autoId = false; @@ -741,7 +741,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { // Create class load helper - ClassLoadHelper loadHelper = null; + ClassLoadHelper loadHelper; try { loadHelper = (ClassLoadHelper) loadClass(classLoadHelperClass).getDeclaredConstructor().newInstance(); } catch (Exception e) { @@ -762,7 +762,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { throw new SchedulerConfigException("No JMX Proxy Scheduler class provided"); } - RemoteMBeanScheduler jmxScheduler = null; + RemoteMBeanScheduler jmxScheduler; try { jmxScheduler = (RemoteMBeanScheduler) loadHelper.loadClass(jmxProxyClass).getDeclaredConstructor() .newInstance(); @@ -942,7 +942,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { // custom connectionProvider... if (cpClass != null) { - ConnectionProvider cp = null; + ConnectionProvider cp; try { cp = (ConnectionProvider) loadHelper.loadClass(cpClass).getDeclaredConstructor().newInstance(); } catch (Exception e) { @@ -1036,7 +1036,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { log.info("Using ConnectionProvider class '" + cpClass + "' for data source '" + dsName + "'"); try { - ConnectionProvider cp = null; + ConnectionProvider cp; try { Constructor constructor = loadHelper.loadClass(cpClass).getConstructor(Properties.class); cp = (ConnectionProvider) constructor.newInstance(pp.getUnderlyingProperties()); @@ -1079,7 +1079,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { + pluginNames[i] + "'"); throw initException; } - SchedulerPlugin plugin = null; + SchedulerPlugin plugin; try { plugin = (SchedulerPlugin) loadHelper.loadClass(plugInClass).getDeclaredConstructor().newInstance(); @@ -1119,7 +1119,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { + jobListenerNames[i] + "'"); throw initException; } - JobListener listener = null; + JobListener listener; try { listener = (JobListener) loadHelper.loadClass(listenerClass).getDeclaredConstructor().newInstance(); @@ -1167,7 +1167,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { + triggerListenerNames[i] + "'"); throw initException; } - TriggerListener listener = null; + TriggerListener listener; try { listener = (TriggerListener) loadHelper.loadClass(listenerClass).getDeclaredConstructor().newInstance(); @@ -1230,7 +1230,7 @@ else if (schedInstId.equals(SYSTEM_PROPERTY_AS_INSTANCE_ID)) { try { - JobRunShellFactory jrsf = null; // Create correct run-shell factory... + JobRunShellFactory jrsf; // Create correct run-shell factory... if (userTXLocation != null) { UserTransactionHelper.setUserTxLocation(userTXLocation); diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/HSQLDBDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/HSQLDBDelegate.java index ebade390d..272e36e0a 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/HSQLDBDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/HSQLDBDelegate.java @@ -65,7 +65,7 @@ protected Object getObjectFromBlob(ResultSet rs, String colName) return null; } - Object obj = null; + Object obj; try (ObjectInputStream in = new ObjectInputStream(binaryInput)) { obj = in.readObject(); diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreCMT.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreCMT.java index 2bc7d2247..9e06d8d37 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreCMT.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreCMT.java @@ -162,7 +162,7 @@ public void shutdown() { @Override protected Connection getNonManagedTXConnection() throws JobPersistenceException { - Connection conn = null; + Connection conn; try { conn = DBConnectionManager.getInstance().getConnection( getNonManagedTXDataSource()); diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/MSSQLDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/MSSQLDelegate.java index 70bead214..887abeda7 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/MSSQLDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/MSSQLDelegate.java @@ -72,7 +72,7 @@ protected Object getObjectFromBlob(ResultSet rs, String colName) return null; } - Object obj = null; + Object obj; try (ObjectInputStream in = new ObjectInputStream(binaryInput)) { obj = in.readObject(); diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PointbaseDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PointbaseDelegate.java index 40feb4289..b93f072c4 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PointbaseDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PointbaseDelegate.java @@ -69,7 +69,7 @@ public int insertJobDetail(Connection conn, JobDetail job) PreparedStatement ps = null; - int insertResult = 0; + int insertResult; try { ps = conn.prepareStatement(rtp(INSERT_JOB_DETAIL)); @@ -114,7 +114,7 @@ public int updateJobDetail(Connection conn, JobDetail job) PreparedStatement ps = null; - int insertResult = 0; + int insertResult; try { ps = conn.prepareStatement(rtp(UPDATE_JOB_DETAIL)); @@ -146,7 +146,7 @@ public int insertTrigger(Connection conn, OperableTrigger trigger, String state, PreparedStatement ps = null; - int insertResult = 0; + int insertResult; try { ps = conn.prepareStatement(rtp(INSERT_TRIGGER)); @@ -207,7 +207,7 @@ public int updateTrigger(Connection conn, OperableTrigger trigger, String state, PreparedStatement ps = null; - int insertResult = 0; + int insertResult; try { diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PostgreSQLDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PostgreSQLDelegate.java index a182e0543..32f49aa5b 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PostgreSQLDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/PostgreSQLDelegate.java @@ -58,7 +58,7 @@ public class PostgreSQLDelegate extends StdJDBCDelegate { @Override protected Object getObjectFromBlob(ResultSet rs, String colName) throws ClassNotFoundException, IOException, SQLException { - InputStream binaryInput = null; + InputStream binaryInput; byte[] bytes = rs.getBytes(colName); Object obj = null; @@ -79,7 +79,7 @@ protected Object getObjectFromBlob(ResultSet rs, String colName) protected Object getJobDataFromBlob(ResultSet rs, String colName) throws ClassNotFoundException, IOException, SQLException { if (canUseProperties()) { - InputStream binaryInput = null; + InputStream binaryInput; byte[] bytes = rs.getBytes(colName); if(bytes == null || bytes.length == 0) { return null; diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/SybaseDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/SybaseDelegate.java index f325cfba9..7a60ef499 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/SybaseDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/SybaseDelegate.java @@ -67,7 +67,7 @@ protected Object getObjectFromBlob(ResultSet rs, String colName) return null; } - Object obj = null; + Object obj; try (ObjectInputStream in = new ObjectInputStream(binaryInput)) { obj = in.readObject(); diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/oracle/OracleDelegate.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/oracle/OracleDelegate.java index 7b6a01397..1ee22a21d 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/oracle/OracleDelegate.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/oracle/OracleDelegate.java @@ -174,7 +174,7 @@ public int insertJobDetail(Connection conn, JobDetail job) int res = 0; - Blob dbBlob = null; + Blob dbBlob; if (rs.next()) { dbBlob = writeDataToBlob(rs, 1, data); } else { @@ -275,7 +275,7 @@ public int insertTrigger(Connection conn, OperableTrigger trigger, String state, PreparedStatement ps = null; ResultSet rs = null; - int insertResult = 0; + int insertResult; try { ps = conn.prepareStatement(rtp(INSERT_TRIGGER)); @@ -330,7 +330,7 @@ public int insertTrigger(Connection conn, OperableTrigger trigger, String state, rs = ps.executeQuery(); - Blob dbBlob = null; + Blob dbBlob; if (rs.next()) { dbBlob = writeDataToBlob(rs, 1, data); } else { @@ -376,7 +376,7 @@ public int updateTrigger(Connection conn, OperableTrigger trigger, String state, PreparedStatement ps2 = null; ResultSet rs = null; - int insertResult = 0; + int insertResult; try { diff --git a/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java b/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java index dfdd84a18..54027faef 100644 --- a/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java +++ b/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java @@ -682,7 +682,7 @@ public Date getFireTimeAfter(Date afterTime) { return null; // d. Calculate and save fireTimeEndDate variable for later use - Date fireTimeEndDate = null; + Date fireTimeEndDate; if (endTimeOfDay == null) fireTimeEndDate = new TimeOfDay(23, 59, 59).getTimeOfDayForDate(fireTime); else diff --git a/quartz/src/main/java/org/quartz/plugins/history/LoggingJobHistoryPlugin.java b/quartz/src/main/java/org/quartz/plugins/history/LoggingJobHistoryPlugin.java index 647f2dc10..178eb43b0 100644 --- a/quartz/src/main/java/org/quartz/plugins/history/LoggingJobHistoryPlugin.java +++ b/quartz/src/main/java/org/quartz/plugins/history/LoggingJobHistoryPlugin.java @@ -477,7 +477,7 @@ public void jobWasExecuted(JobExecutionContext context, Trigger trigger = context.getTrigger(); - Object[] args = null; + Object[] args; if (jobException != null) { if (!getLog().isWarnEnabled()) { diff --git a/quartz/src/main/java/org/quartz/plugins/xml/FileScanJob.java b/quartz/src/main/java/org/quartz/plugins/xml/FileScanJob.java index f76873952..d7cf7d904 100644 --- a/quartz/src/main/java/org/quartz/plugins/xml/FileScanJob.java +++ b/quartz/src/main/java/org/quartz/plugins/xml/FileScanJob.java @@ -79,7 +79,7 @@ public FileScanJob() { */ public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap mergedJobDataMap = context.getMergedJobDataMap(); - SchedulerContext schedCtx = null; + SchedulerContext schedCtx; try { schedCtx = context.getScheduler().getContext(); } catch (SchedulerException e) { diff --git a/quartz/src/main/java/org/quartz/simpl/SimpleThreadPool.java b/quartz/src/main/java/org/quartz/simpl/SimpleThreadPool.java index 4bfe34e06..73f001162 100644 --- a/quartz/src/main/java/org/quartz/simpl/SimpleThreadPool.java +++ b/quartz/src/main/java/org/quartz/simpl/SimpleThreadPool.java @@ -490,7 +490,7 @@ class WorkerThread extends Thread { private final SimpleThreadPool tp; - private Runnable runnable = null; + private Runnable runnable; private boolean runOnce = false; diff --git a/quartz/src/main/java/org/quartz/utils/JNDIConnectionProvider.java b/quartz/src/main/java/org/quartz/utils/JNDIConnectionProvider.java index 8c47c6111..6cee5f902 100644 --- a/quartz/src/main/java/org/quartz/utils/JNDIConnectionProvider.java +++ b/quartz/src/main/java/org/quartz/utils/JNDIConnectionProvider.java @@ -62,7 +62,7 @@ public class JNDIConnectionProvider implements ConnectionProvider { private Object datasource; - private boolean alwaysLookup = false; + private boolean alwaysLookup; private final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/quartz/src/main/java/org/quartz/utils/PropertiesParser.java b/quartz/src/main/java/org/quartz/utils/PropertiesParser.java index 878624d86..b32533712 100644 --- a/quartz/src/main/java/org/quartz/utils/PropertiesParser.java +++ b/quartz/src/main/java/org/quartz/utils/PropertiesParser.java @@ -41,7 +41,7 @@ public class PropertiesParser { * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - Properties props = null; + Properties props; /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/quartz/src/main/java/org/quartz/xml/XMLSchedulingDataProcessor.java b/quartz/src/main/java/org/quartz/xml/XMLSchedulingDataProcessor.java index 031591ffc..a80a0fa09 100644 --- a/quartz/src/main/java/org/quartz/xml/XMLSchedulingDataProcessor.java +++ b/quartz/src/main/java/org/quartz/xml/XMLSchedulingDataProcessor.java @@ -599,7 +599,7 @@ protected void process(InputSource is) throws SAXException, IOException, ParseEx for (int i = 0; i < jobNodes.getLength(); i++) { Node jobDetailNode = jobNodes.item(i); - String t = null; + String t; String jobName = getTrimmedToNullString(xpath, "q:name", jobDetailNode); String jobGroup = getTrimmedToNullString(xpath, "q:group", jobDetailNode);