Closes #2521 - Fix code smells Stream.collect(Collectors.toList()) to Stream.toList()

This commit is contained in:
Maria Margaritis 2024-03-05 23:08:09 +01:00
parent 527bf4abf1
commit 1ae484f775
1 changed files with 3 additions and 5 deletions

View File

@ -8,7 +8,6 @@ import java.time.Instant;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.TaskanaConfiguration; import pro.taskana.TaskanaConfiguration;
@ -108,7 +107,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
.filter(not(entry -> entry.getKey().isEmpty())) .filter(not(entry -> entry.getKey().isEmpty()))
.filter(not(entry -> entry.getValue().equals(countParentTask.get(entry.getKey())))) .filter(not(entry -> entry.getValue().equals(countParentTask.get(entry.getKey()))))
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.collect(Collectors.toList()); .toList();
tasksToDelete = tasksToDelete =
tasksToDelete.stream() tasksToDelete.stream()
@ -116,7 +115,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
taskSummary -> taskSummary ->
!taskIdsNotAllCompletedSameParentBusiness.contains( !taskIdsNotAllCompletedSameParentBusiness.contains(
taskSummary.getParentBusinessProcessId())) taskSummary.getParentBusinessProcessId()))
.collect(Collectors.toList()); .toList();
} }
return tasksToDelete; return tasksToDelete;
@ -138,8 +137,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
private int deleteTasks(List<TaskSummary> tasksToBeDeleted) private int deleteTasks(List<TaskSummary> tasksToBeDeleted)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
List<String> tasksIdsToBeDeleted = List<String> tasksIdsToBeDeleted = tasksToBeDeleted.stream().map(TaskSummary::getId).toList();
tasksToBeDeleted.stream().map(TaskSummary::getId).collect(Collectors.toList());
BulkOperationResults<String, TaskanaException> results = BulkOperationResults<String, TaskanaException> results =
taskanaEngineImpl.getTaskService().deleteTasks(tasksIdsToBeDeleted); taskanaEngineImpl.getTaskService().deleteTasks(tasksIdsToBeDeleted);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {