Cleanup code smells reported by Sonar
This is a first pass are removing some of the code smells. Many reported code smells were ignored in this effort
This commit is contained in:
committed by
Mark Pollack
parent
fa3e4e55c6
commit
8e1d38a76a
@@ -50,10 +50,8 @@ public class TaskBatchExecutionListenerBeanPostProcessor implements BeanPostProc
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
if(jobNames.size() > 0) {
|
||||
if(!jobNames.contains(beanName)) {
|
||||
if(jobNames.size() > 0 && !jobNames.contains(beanName)) {
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
int length = this.applicationContext
|
||||
.getBeanNamesForType(TaskBatchExecutionListener.class).length;
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties(prefix = "spring.cloud.task.batch")
|
||||
public class TaskBatchProperties {
|
||||
|
||||
private static final long DEFAULT_POLL_INTERVAL = 5000L;
|
||||
/**
|
||||
* Comma-separated list of job names to execute on startup (for instance,
|
||||
* `job1,job2`). By default, all Jobs found in the context are executed.
|
||||
@@ -49,7 +50,7 @@ public class TaskBatchProperties {
|
||||
* when spring.cloud.task.batch.failOnJobFailure is set to true. Defaults
|
||||
* to 5000.
|
||||
*/
|
||||
private long failOnJobFailurePollInterval = 5000l;
|
||||
private long failOnJobFailurePollInterval = DEFAULT_POLL_INTERVAL;
|
||||
|
||||
public String getJobNames() {
|
||||
return this.jobNames;
|
||||
|
||||
@@ -18,19 +18,14 @@ package org.springframework.cloud.task.batch.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.configuration.JobRegistry;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||
import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TaskBatchExecutionListener extends JobExecutionListenerSupport {
|
||||
|
||||
private TaskBatchDao taskBatchDao;
|
||||
|
||||
private final static Log logger = LogFactory.getLog(TaskBatchExecutionListener.class);
|
||||
private static final Log logger = LogFactory.getLog(TaskBatchExecutionListener.class);
|
||||
|
||||
/**
|
||||
* @param taskBatchDao dao used to persist the relationship. Must not be null
|
||||
|
||||
@@ -68,6 +68,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAware, InitializingBean {
|
||||
|
||||
private static final long DEFAULT_POLL_INTERVAL = 10000;
|
||||
|
||||
public static final String SPRING_CLOUD_TASK_JOB_EXECUTION_ID =
|
||||
"spring.cloud.task.job-execution-id";
|
||||
|
||||
@@ -100,7 +102,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw
|
||||
|
||||
private Log logger = LogFactory.getLog(DeployerPartitionHandler.class);
|
||||
|
||||
private long pollInterval = 10000;
|
||||
private long pollInterval = DEFAULT_POLL_INTERVAL;
|
||||
|
||||
private long timeout = -1;
|
||||
|
||||
@@ -352,7 +354,8 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw
|
||||
StepExecution partitionStepExecution =
|
||||
jobExplorer.getStepExecution(masterStepExecution.getJobExecutionId(), curStepExecution.getId());
|
||||
|
||||
if (isComplete(partitionStepExecution.getStatus())) {
|
||||
BatchStatus batchStatus = partitionStepExecution.getStatus();
|
||||
if (batchStatus != null && isComplete(batchStatus)) {
|
||||
result.add(partitionStepExecution);
|
||||
currentWorkers--;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user