Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 16edca1

Browse files
authored
$END will not be validated as a app
- Updated to check task.name instead of task.taskName - Updated to verify that taskNode.getName is not null before assessing if it contains $END - resolves #4387
1 parent 386ab7b commit 16edca1

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/service/impl/DefaultTaskSaveService.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,17 @@ public void saveTaskDefinition(TaskDefinition taskDefinition) {
9999
if (taskNode.isComposed()) {
100100
// Create the child task definitions needed for the composed task
101101
taskNode.getTaskApps().forEach(task -> {
102-
String labelPrefix = StringUtils.hasText(task.getLabel()) ? task.getLabel() + ":" : "";
103-
// Add arguments to child task definitions
104-
String generatedTaskDSL = labelPrefix + task.getName() + task.getArguments().entrySet().stream()
105-
.map(argument -> String.format(" --%s=%s", argument.getKey(),
106-
DefinitionUtils.autoQuotes(argument.getValue())))
107-
.collect(Collectors.joining());
108-
TaskDefinition composedTaskElementDefinition = new TaskDefinition(task.getExecutableDSLName(),
109-
generatedTaskDSL);
110-
saveStandardTaskDefinition(composedTaskElementDefinition);
102+
if (StringUtils.hasText(task.getName()) && !task.getName().equals("$END")) {
103+
String labelPrefix = StringUtils.hasText(task.getLabel()) ? task.getLabel() + ":" : "";
104+
// Add arguments to child task definitions
105+
String generatedTaskDSL = labelPrefix + task.getName() + task.getArguments().entrySet().stream()
106+
.map(argument -> String.format(" --%s=%s", argument.getKey(),
107+
DefinitionUtils.autoQuotes(argument.getValue())))
108+
.collect(Collectors.joining());
109+
TaskDefinition composedTaskElementDefinition = new TaskDefinition(task.getExecutableDSLName(),
110+
generatedTaskDSL);
111+
saveStandardTaskDefinition(composedTaskElementDefinition);
112+
}
111113
});
112114
taskDefinitionRepository.save(taskDefinition);
113115
}

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/service/impl/DefaultTaskExecutionServiceTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,28 @@ public void executeComposedTaskwithUserCTRName() {
13551355
assertNull(request.getDefinition().getProperties().get("globalstreamkey"));
13561356
}
13571357

1358+
@Test
1359+
@DirtiesContext
1360+
public void executeComposedTaskWithEnd() {
1361+
String dsl = "timestamp '*'->t1: timestamp 'FOO'->$END";
1362+
initializeSuccessfulRegistry(appRegistry);
1363+
1364+
taskSaveService.saveTaskDefinition(new TaskDefinition("transitionTask", dsl));
1365+
when(taskLauncher.launch(any())).thenReturn("0");
1366+
1367+
Map<String, String> properties = new HashMap<>();
1368+
properties.put("app.t1.timestamp.format", "YYYY");
1369+
assertEquals(1L, this.taskExecutionService.executeTask("transitionTask", properties, new LinkedList<>()));
1370+
ArgumentCaptor<AppDeploymentRequest> argumentCaptor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
1371+
verify(this.taskLauncher, atLeast(1)).launch(argumentCaptor.capture());
1372+
1373+
AppDeploymentRequest request = argumentCaptor.getValue();
1374+
assertEquals("transitionTask", request.getDefinition().getProperties().get("spring.cloud.task.name"));
1375+
assertEquals("YYYY",
1376+
request.getDefinition().getProperties().get("composed-task-app-properties.app.t1.timestamp.format"));
1377+
1378+
}
1379+
13581380
@Test
13591381
@DirtiesContext
13601382
public void executeComposedTaskWithLabels() {

0 commit comments

Comments
 (0)