Skip to content

Commit

Permalink
Update TaskTemplate.launch to provide backwards compatible behaviour …
Browse files Browse the repository at this point in the history
…for old client. #5492
  • Loading branch information
corneil committed Oct 5, 2023
1 parent 69444d7 commit ea0157a
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.springframework.cloud.dataflow.rest.client;

import javax.naming.OperationNotSupportedException;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -175,15 +177,22 @@ public TaskDefinitionResource create(String name, String definition, String desc
return restTemplate.postForObject(definitionsLink.expand().getHref(), values,
TaskDefinitionResource.class);
}

private boolean isOldServer() {
for(String version : Arrays.asList("2.10.", "1.5.", "2.9.", "1.4.")) {

This comment has been minimized.

Copy link
@ilayaperumalg

ilayaperumalg Oct 5, 2023

Contributor

Can we use a better logic to check if we can go below the SCDF 2.11 or 1.6 instead of hard coded values?

This comment has been minimized.

Copy link
@ilayaperumalg

ilayaperumalg Oct 5, 2023

Contributor

and, what happens if the dataServerVersion is null?

This comment has been minimized.

Copy link
@ilayaperumalg

ilayaperumalg Oct 5, 2023

Contributor

As discussed, let's try to use the AboutResource to infer the data flow version as the client side dataflowServerVersion isn't reliable.

if(this.dataFlowServerVersion.contains(version)) {
return true;
}
}
return false;
}
@Override
public LaunchResponseResource launch(String name, Map<String, String> properties, List<String> arguments) {
MultiValueMap<String, Object> values = new LinkedMultiValueMap<>();
String formattedProperties = DeploymentPropertiesUtils.format(properties);
String commandLineArguments = StringUtils.collectionToDelimitedString(arguments, " ");
values.add("properties", formattedProperties);
values.add("arguments", commandLineArguments);
if(this.dataFlowServerVersion.contains("2.10") || this.dataFlowServerVersion.contains("1.5")) {
if(isOldServer()) {
Long id = restTemplate.postForObject(executionByNameLink.expand(name).getHref(), values, Long.class, name);
if(id != null) {
LaunchResponseResource response = new LaunchResponseResource();
Expand Down

0 comments on commit ea0157a

Please sign in to comment.