-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix]Fix the problem of "," being divided in [] (#5401)
* Fix the problem of "," being divided in [] * Update seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/command/ParameterSplitter.java Co-authored-by: Wenjun Ruan <[email protected]> * fix error * fix bug * fix bug --------- Co-authored-by: Wenjun Ruan <[email protected]>
- Loading branch information
1 parent
7903db7
commit d8c92a1
Showing
5 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...re-starter/src/main/java/org/apache/seatunnel/core/starter/command/ParameterSplitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.seatunnel.core.starter.command; | ||
|
||
import com.beust.jcommander.converters.IParameterSplitter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class ParameterSplitter implements IParameterSplitter { | ||
|
||
@Override | ||
public List<String> split(String value) { | ||
if (!value.contains(",")) { | ||
return Collections.singletonList(value); | ||
} | ||
|
||
List<String> result = new ArrayList<>(); | ||
StringBuilder currentToken = new StringBuilder(); | ||
boolean insideBrackets = false; | ||
|
||
for (char c : value.toCharArray()) { | ||
if (c == '[') { | ||
insideBrackets = true; | ||
} else if (c == ']') { | ||
insideBrackets = false; | ||
} | ||
|
||
if (c == ',' && !insideBrackets) { | ||
result.add(currentToken.toString().trim()); | ||
currentToken = new StringBuilder(); | ||
} else { | ||
currentToken.append(c); | ||
} | ||
} | ||
|
||
if (currentToken.length() > 0) { | ||
result.add(currentToken.toString().trim()); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters