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:
Glenn Renfro
2018-11-15 12:57:58 -05:00
committed by Mark Pollack
parent fa3e4e55c6
commit 8e1d38a76a
23 changed files with 50 additions and 46 deletions

View File

@@ -49,7 +49,7 @@ import org.springframework.integration.support.locks.LockRegistry;
*/
public class SingleInstanceTaskListener implements ApplicationListener<ApplicationEvent> {
private final static Log logger = LogFactory.getLog(SingleInstanceTaskListener.class);
private static final Log logger = LogFactory.getLog(SingleInstanceTaskListener.class);
private LockRegistry lockRegistry;

View File

@@ -16,21 +16,15 @@
package org.springframework.cloud.task.configuration;
import java.util.Collection;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.task.repository.support.SimpleTaskNameResolver;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.integration.support.locks.PassThruLockRegistry;
import org.springframework.util.CollectionUtils;
/**
* Autoconfiguration of {@link SingleInstanceTaskListener}.

View File

@@ -31,6 +31,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "spring.cloud.task")
public class TaskProperties {
private static final int DEFAULT_CHECK_INTERVAL = 500;
private static final Log logger = LogFactory.getLog(TaskProperties.class);
public static final String DEFAULT_TABLE_PREFIX = "TASK_";
@@ -82,7 +85,7 @@ public class TaskProperties {
* Declares the time (in millis) that a task execution will wait between
* checks. Default time is: 500 millis.
*/
private int singleInstanceLockCheckInterval = 500;
private int singleInstanceLockCheckInterval = DEFAULT_CHECK_INTERVAL;
public String getExternalExecutionId() {
return externalExecutionId;

View File

@@ -29,14 +29,14 @@ public interface TaskExecutionListener {
* Invoked after the {@link TaskExecution} has been stored in the {@link TaskRepository}.
* @param taskExecution instance containing the information about the current task.
*/
public void onTaskStartup(TaskExecution taskExecution);
void onTaskStartup(TaskExecution taskExecution);
/**
* Invoked before the {@link TaskExecution} has been updated in the {@link TaskRepository}
* upon task end.
* @param taskExecution instance containing the information about the current task.
*/
public void onTaskEnd(TaskExecution taskExecution);
void onTaskEnd(TaskExecution taskExecution);
/**
* Invoked if an uncaught exception occurs during a task execution. This invocation
@@ -45,5 +45,5 @@ public interface TaskExecutionListener {
* @param taskExecution instance containing the information about the current task.
* @param throwable the uncaught exception that was thrown during task execution.
*/
public void onTaskFailed(TaskExecution taskExecution, Throwable throwable);
void onTaskFailed(TaskExecution taskExecution, Throwable throwable);
}

View File

@@ -85,7 +85,7 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
private List<TaskExecutionListener> taskExecutionListeners;
private final static Log logger = LogFactory.getLog(TaskLifecycleListener.class);
private static final Log logger = LogFactory.getLog(TaskLifecycleListener.class);
private final TaskRepository taskRepository;

View File

@@ -49,7 +49,7 @@ import org.springframework.core.annotation.AnnotationUtils;
*/
public class TaskListenerExecutorObjectFactory implements ObjectFactory<TaskExecutionListener> {
private final static Log logger = LogFactory.getLog(TaskListenerExecutor.class);
private static final Log logger = LogFactory.getLog(TaskListenerExecutor.class);
private final Set<Class<?>> nonAnnotatedClasses =
Collections.newSetFromMap(new ConcurrentHashMap<>());

View File

@@ -46,7 +46,6 @@ import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -568,7 +567,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
*/
private final class TaskExecutionRowMapper implements RowMapper<TaskExecution> {
public TaskExecutionRowMapper() {
private TaskExecutionRowMapper() {
}
@Override

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.task.repository.dao;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -322,7 +323,7 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
}
}
private static class TaskExecutionComparator implements Comparator<TaskExecution> {
private static class TaskExecutionComparator implements Comparator<TaskExecution>, Serializable {
@Override
public int compare(TaskExecution firstTaskExecution, TaskExecution secondTaskExecution) {
if (firstTaskExecution.getStartTime().equals(secondTaskExecution.getStartTime())) {

View File

@@ -50,7 +50,7 @@ public enum DatabaseType {
private final String productName;
private DatabaseType(String productName) {
DatabaseType(String productName) {
this.productName = productName;
}

View File

@@ -39,7 +39,7 @@ public class SimpleTaskRepository implements TaskRepository {
public static final int MAX_TASK_NAME_SIZE = 100;
public static final int MAX_ERROR_MESSAGE_SIZE = 2500;
private final static Log logger = LogFactory.getLog(SimpleTaskRepository.class);
private static final Log logger = LogFactory.getLog(SimpleTaskRepository.class);
private TaskExecutionDao taskExecutionDao;