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

Commit 7b09e35

Browse files
committed
StreamDefinitionToDslConverter produces invalid DSL
Resolves #2033
1 parent 1509522 commit 7b09e35

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

spring-cloud-dataflow-core/src/main/java/org/springframework/cloud/dataflow/core/StreamDefinitionToDslConverter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ public String toDsl(List<StreamAppDefinition> appDefinitions) {
112112
}
113113

114114
private String autoQuotes(String propertyValue) {
115-
if (propertyValue.contains(" ") && !propertyValue.contains("'")) {
116-
return "'" + propertyValue + "'";
115+
if (!propertyValue.contains("'")) {
116+
if (propertyValue.contains(" ") || propertyValue.contains(";") || propertyValue.contains("*")) {
117+
return "'" + propertyValue + "'";
118+
}
117119
}
118120
return propertyValue;
119121
}

spring-cloud-dataflow-core/src/test/java/org/springframework/cloud/dataflow/core/StreamDefinitionToDslConverterTests.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,49 @@ public void testPropertyAutoQuotes() {
187187
new StreamDefinitionToDslConverter().toDsl(Arrays.asList(foo2, bar2)));
188188
}
189189

190+
@Test
191+
public void autoQuotesOnSemicolonProperties() {
192+
193+
StreamDefinition streamDefinition = new StreamDefinition("streamName",
194+
"http-source-kafka --server.port=9900 | couchbase-sink-kafka " +
195+
"--inputType=\"application/x-java-object;type=com.example.dto.InputDto\"");
196+
197+
assertEquals("http-source-kafka --server.port=9900 | couchbase-sink-kafka " +
198+
"--spring.cloud.stream.bindings.input.contentType='application/x-java-object;type=com.example.dto.InputDto'",
199+
new StreamDefinitionToDslConverter().toDsl(streamDefinition));
200+
201+
202+
streamDefinition = new StreamDefinition("stream2", "jdbc-mssql --cron='/10 * * * * *' " +
203+
"--max-messages=-1 --password='******' --query='UPDATE top (100) ASSURANCE SET assurance_flag = 1 " +
204+
"OUTPUT Inserted.* WHERE assurance_flag IS NULL' " +
205+
"--url='jdbc:sqlserver://db:1433;databaseName=Spring' --username='*****' | " +
206+
"cust-processor | router --default-output-channel=out");
207+
208+
assertEquals("jdbc-mssql --cron='/10 * * * * *' " +
209+
"--max-messages=-1 --password='******' --query='UPDATE top (100) ASSURANCE SET assurance_flag = 1 " +
210+
"OUTPUT Inserted.* WHERE assurance_flag IS NULL' " +
211+
"--url='jdbc:sqlserver://db:1433;databaseName=Spring' --username='*****' | " +
212+
"cust-processor | router --default-output-channel=out",
213+
new StreamDefinitionToDslConverter().toDsl(streamDefinition));
214+
215+
}
216+
217+
@Test
218+
public void autoQuotesOnStarProperties() {
219+
220+
StreamDefinition streamDefinition = new StreamDefinition("stream2", "jdbc-mssql --cron='/10 * * * * *' " +
221+
"--max-messages=-1 --password='******' --query='UPDATE top (100) ASSURANCE SET assurance_flag = 1 " +
222+
"OUTPUT Inserted.* WHERE assurance_flag IS NULL' " +
223+
"--url='jdbc:sqlserver://db:1433;databaseName=Spring' --username='*****' | " +
224+
"cust-processor | router --default-output-channel=out");
225+
226+
assertEquals("jdbc-mssql --cron='/10 * * * * *' " +
227+
"--max-messages=-1 --password='******' --query='UPDATE top (100) ASSURANCE SET assurance_flag = 1 " +
228+
"OUTPUT Inserted.* WHERE assurance_flag IS NULL' " +
229+
"--url='jdbc:sqlserver://db:1433;databaseName=Spring' --username='*****' | " +
230+
"cust-processor | router --default-output-channel=out",
231+
new StreamDefinitionToDslConverter().toDsl(streamDefinition));
232+
233+
}
234+
190235
}

0 commit comments

Comments
 (0)