Skip to content

Commit 88845f8

Browse files
committed
resolve NumberFormatException
1 parent 3664681 commit 88845f8

File tree

1 file changed

+3
-11
lines changed
  • dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-trino/src/main/java/org/apache/dolphinscheduler/plugin/datasource/trino/param

1 file changed

+3
-11
lines changed

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-trino/src/main/java/org/apache/dolphinscheduler/plugin/datasource/trino/param/TrinoDataSourceProcessor.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ public BaseDataSourceParamDTO createDatasourceParamDTO(String connectionJson) {
5757
String[] hostPortArray = hostSeperator[hostSeperator.length - 1].split(Constants.COMMA);
5858

5959
TrinoDataSourceParamDTO TrinoDatasourceParamDTO = new TrinoDataSourceParamDTO();
60-
if (isNumeric(hostPortArray[0].split(Constants.COLON)[1])) {
61-
TrinoDatasourceParamDTO.setPort(Integer.valueOf(hostPortArray[0].split(Constants.COLON)[1]));
62-
}
63-
TrinoDatasourceParamDTO.setHost(hostPortArray[0].split(Constants.COLON)[0]);
60+
String[] split = hostPortArray[0].split(Constants.COLON);
61+
TrinoDatasourceParamDTO.setHost(split[0]);
62+
TrinoDatasourceParamDTO.setPort(Integer.valueOf(split[1]));
6463
TrinoDatasourceParamDTO.setDatabase(connectionParams.getDatabase());
6564
TrinoDatasourceParamDTO.setUserName(connectionParams.getUser());
6665
TrinoDatasourceParamDTO.setOther(parseOther(connectionParams.getOther()));
@@ -151,11 +150,4 @@ private Map<String, String> parseOther(String other) {
151150
}
152151
return otherMap;
153152
}
154-
public boolean isNumeric(String str) {
155-
if (str != null && !"".equals(str.trim())) {
156-
return str.matches("^[0-9]*$");
157-
} else {
158-
return false;
159-
}
160-
}
161153
}

0 commit comments

Comments
 (0)