TSK-520: Replaced code smells found by FindBugs

This commit is contained in:
BVier 2018-06-06 10:55:08 +02:00 committed by Holger Hagen
parent 2b1ee855cf
commit dd0ad1253a
5 changed files with 21 additions and 7 deletions

View File

@ -98,7 +98,7 @@ public class ClassificationServiceImpl implements ClassificationService {
}
private void addClassificationToRootDomain(ClassificationImpl classificationImpl) {
if (classificationImpl.getDomain() != "") {
if (!classificationImpl.getDomain().equals("")) {
boolean doesExist = true;
String idBackup = classificationImpl.getId();
String domainBackup = classificationImpl.getDomain();
@ -178,7 +178,14 @@ public class ClassificationServiceImpl implements ClassificationService {
}
classificationMapper.update(classificationImpl);
boolean priorityChanged = oldClassification.getPriority() != classification.getPriority();
boolean serviceLevelChanged = oldClassification.getServiceLevel() != classification.getServiceLevel();
boolean serviceLevelChanged = true;
if (oldClassification.getServiceLevel() == null) {
if (classification.getServiceLevel() == null) {
serviceLevelChanged = false;
}
} else if (oldClassification.getServiceLevel().equals(classification.getServiceLevel())) {
serviceLevelChanged = false;
}
if (priorityChanged || serviceLevelChanged) {
Map<String, String> args = new HashMap<>();

View File

@ -297,7 +297,7 @@ public class TaskServiceImpl implements TaskService {
TaskImpl task = (TaskImpl) taskToCreate;
try {
taskanaEngine.openConnection();
if (task.getId() != "" && task.getId() != null) {
if (task.getId() != null && !task.getId().equals("")) {
throw new TaskAlreadyExistException(task.getId());
} else {
LOGGER.debug("Task {} cannot be be found, so it can be created.", task.getId());

View File

@ -4,6 +4,7 @@ import java.security.Principal;
import java.security.acl.Group;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
/**
@ -16,6 +17,7 @@ public class GroupPrincipal implements Group {
public GroupPrincipal(String name) {
this.name = name;
this.members = new HashSet<Principal>();
}
@Override

View File

@ -79,7 +79,9 @@ public class TestDataGenerator {
.forEach(runner::runScript);
} finally {
runner.closeConnection();
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
@ -109,8 +111,9 @@ public class TestDataGenerator {
new ByteArrayInputStream(
sqlReplacer.monitoringTestDataSql.getBytes(StandardCharsets.UTF_8))));
} finally {
runner.closeConnection();
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());

View File

@ -34,7 +34,9 @@ public abstract class AbstractPagingController {
protected String[] extractCommaSeparatedFields(List<String> list) {
List<String> values = new ArrayList<>();
list.forEach(item -> values.addAll(Arrays.asList(item.split(","))));
if (list != null) {
list.forEach(item -> values.addAll(Arrays.asList(item.split(","))));
}
return values.toArray(new String[0]);
}