Skip to content

Commit 7d563cb

Browse files
committed
Respect 'manifest' task def controller parameter
Do not execute SQL to load manifest when parameter is 'false'.
1 parent fc17b23 commit 7d563cb

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskDefinitionController.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.function.Function;
24+
import java.util.stream.Collectors;
2425

2526
import org.springframework.cloud.dataflow.core.TaskDefinition;
2627
import org.springframework.cloud.dataflow.core.dsl.TaskNode;
@@ -62,6 +63,7 @@
6263
* @author Gunnar Hillert
6364
* @author Daniel Serleg
6465
* @author Ilayaperumal Gopinathan
66+
* @author Chris Bono
6567
*/
6668
@RestController
6769
@RequestMapping("/tasks/definitions")
@@ -176,20 +178,12 @@ public PagedModel<? extends TaskDefinitionResource> list(Pageable pageable, @Req
176178
}
177179
}
178180

179-
final java.util.HashMap<String, TaskDefinition> taskDefinitionMap = new java.util.HashMap<>();
180-
181-
for (TaskDefinition taskDefinition : taskDefinitions) {
182-
taskDefinitionMap.put(taskDefinition.getName(), taskDefinition);
183-
}
184-
185-
final List<TaskExecution> taskExecutions;
181+
final Map<String, TaskDefinition> taskDefinitionMap = taskDefinitions.stream()
182+
.collect(Collectors.toMap(TaskDefinition::getTaskName, Function.identity()));
186183

184+
List<TaskExecution> taskExecutions = null;
187185
if (!taskDefinitionMap.isEmpty()) {
188-
taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames(
189-
taskDefinitionMap.keySet().toArray(new String[taskDefinitionMap.size()]));
190-
}
191-
else {
192-
taskExecutions = null;
186+
taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames(taskDefinitionMap.keySet().toArray(new String[0]));
193187
}
194188

195189
final Page<TaskExecutionAwareTaskDefinition> taskExecutionAwareTaskDefinitions = taskDefinitions

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultTaskDefinitionAssembler.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,11 @@
4040
/**
4141
* {@link org.springframework.hateoas.server.RepresentationModelAssembler} implementation that converts
4242
* {@link TaskDefinition}s to {@link TaskDefinitionResource}s.
43+
*
44+
* @author Ilayaperumal Gopinathan
45+
* @author Evgeniy Bezdomnikov
46+
* @author Glenn Renfro
47+
* @author Chris Bono
4348
*/
4449
public class DefaultTaskDefinitionAssembler<R extends TaskDefinitionResource> extends
4550
RepresentationModelAssemblerSupport<TaskExecutionAwareTaskDefinition, R> {
@@ -73,10 +78,13 @@ TaskDefinitionResource updateTaskExecutionResource(
7378

7479
TaskExecution taskExecution = taskExecutionAwareTaskDefinition.getLatestTaskExecution();
7580
taskExecution = this.taskSanitizer.sanitizeTaskExecutionArguments(taskExecution);
76-
TaskManifest taskManifest = this.taskExecutionService.findTaskManifestById(taskExecution.getExecutionId());
77-
taskManifest = this.taskSanitizer.sanitizeTaskManifest(taskManifest);
81+
TaskManifest taskManifest = null;
82+
if (manifest) {
83+
taskManifest = this.taskExecutionService.findTaskManifestById(taskExecution.getExecutionId());
84+
taskManifest = this.taskSanitizer.sanitizeTaskManifest(taskManifest);
85+
}
7886
TaskJobExecution composedTaskJobExecution = null;
79-
if(taskExecution != null && taskDefinitionResource.isComposed()) {
87+
if (taskExecution != null && taskDefinitionResource.isComposed()) {
8088
Set<Long> jobExecutionIds = this.taskExplorer.getJobExecutionIdsByTaskExecutionId(taskExecution.getExecutionId());
8189
if(jobExecutionIds != null && jobExecutionIds.size() > 0) {
8290
try {

0 commit comments

Comments
 (0)