diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java index ede16a2ca76b..bdcf25c3e71d 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Field; -import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutorService; @@ -135,7 +134,6 @@ private void buildProcess(String commandFile) throws IOException { } } command.add(commandInterpreter()); - command.addAll(Collections.emptyList()); command.add(commandFile); // setting commands diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java index 29948cac2980..d92f8e42ce96 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java @@ -91,24 +91,24 @@ protected void createCommandFileIfNotExists(String execCommand, String commandFi StringBuilder sb = new StringBuilder(); if (SystemUtils.IS_OS_WINDOWS) { - sb.append("@echo off\n"); - sb.append("cd /d %~dp0\n"); + sb.append("@echo off").append(System.lineSeparator()); + sb.append("cd /d %~dp0").append(System.lineSeparator()); if (StringUtils.isNotBlank(taskRequest.getEnvironmentConfig())) { - sb.append(taskRequest.getEnvironmentConfig()).append("\n"); + sb.append(taskRequest.getEnvironmentConfig()).append(System.lineSeparator()); } else { if (taskRequest.getEnvFile() != null) { - sb.append("call ").append(taskRequest.getEnvFile()).append("\n"); + sb.append("call ").append(taskRequest.getEnvFile()).append(System.lineSeparator()); } } } else { - sb.append("#!/bin/bash\n"); - sb.append("BASEDIR=$(cd `dirname $0`; pwd)\n"); - sb.append("cd $BASEDIR\n"); + sb.append("#!/bin/bash").append(System.lineSeparator()); + sb.append("BASEDIR=$(cd `dirname $0`; pwd)").append(System.lineSeparator()); + sb.append("cd $BASEDIR").append(System.lineSeparator()); if (StringUtils.isNotBlank(taskRequest.getEnvironmentConfig())) { - sb.append(taskRequest.getEnvironmentConfig()).append("\n"); + sb.append(taskRequest.getEnvironmentConfig()).append(System.lineSeparator()); } else { if (taskRequest.getEnvFile() != null) { - sb.append("source ").append(taskRequest.getEnvFile()).append("\n"); + sb.append("source ").append(taskRequest.getEnvFile()).append(System.lineSeparator()); } } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java index f7afeedeaace..0dc3086ec57d 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java @@ -209,7 +209,7 @@ private String buildDataxJsonFile(Map paramsMap) throws Except } if (dataXParameters.getCustomConfig() == Flag.YES.ordinal()) { - json = dataXParameters.getJson().replaceAll("\\r\\n", "\n"); + json = dataXParameters.getJson().replaceAll("\\r\\n", System.lineSeparator()); } else { ObjectNode job = JSONUtils.createObjectNode(); job.putArray("content").addAll(buildDataxJobContentJson()); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java index 7b0981215fae..6206c086bbbc 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java @@ -89,7 +89,7 @@ public void init() { @Override public String getPreScript() { - String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", "\n"); + String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); try { rawPythonScript = convertPythonScriptPlaceholders(rawPythonScript); } catch (StringIndexOutOfBoundsException e) { @@ -182,9 +182,9 @@ protected void createPythonCommandFileIfNotExists(String pythonScript, String py logger.info("generate python script file:{}", pythonScriptFile); StringBuilder sb = new StringBuilder(); - sb.append("#-*- encoding=utf8 -*-\n"); + sb.append("#-*- encoding=utf8 -*-").append(System.lineSeparator()); - sb.append("\n\n"); + sb.append(System.lineSeparator()); sb.append(pythonScript); logger.info(sb.toString()); @@ -212,7 +212,7 @@ protected String buildPythonCommandFilePath() { */ protected String buildPythonScriptContent() throws Exception { logger.info("raw python script : {}", pythonParameters.getRawScript()); - String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", "\n"); + String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); Map paramsMap = mergeParamsWithContext(pythonParameters); return ParameterUtils.convertParameterPlaceholders(rawPythonScript, ParamUtils.convert(paramsMap)); } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java index 3d896adc5809..5433f3d8285d 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java @@ -172,7 +172,7 @@ protected String buildCustomConfigCommand() throws Exception { private String buildCustomConfigContent() { logger.info("raw custom config content : {}", seatunnelParameters.getRawScript()); - String script = seatunnelParameters.getRawScript().replaceAll("\\r\\n", "\n"); + String script = seatunnelParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); script = parseScript(script); return script; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java index 13f299702d6d..681920c0c191 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java @@ -137,7 +137,7 @@ private String buildCommand() throws Exception { return fileName; } - String script = shellParameters.getRawScript().replaceAll("\\r\\n", "\n"); + String script = shellParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); script = parseScript(script); shellParameters.setRawScript(script); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java index f8f2855e715d..b71ebc9e1974 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java @@ -254,7 +254,7 @@ private String generateScriptFile() { } private String replaceParam(String script) { - script = script.replaceAll("\\r\\n", "\n"); + script = script.replaceAll("\\r\\n", System.lineSeparator()); // replace placeholder, and combining local and global parameters Map paramsMap = taskExecutionContext.getPrepareParamsMap(); script = ParameterUtils.convertParameterPlaceholders(script, ParamUtils.convert(paramsMap)); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java index 48d152f70d29..df5169758bea 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java @@ -80,7 +80,7 @@ public String generateSqoopJob(SqoopParameters sqoopParameters, sourceGenerator.generate(sqoopParameters, sqoopTaskExecutionContext), targetGenerator.generate(sqoopParameters, sqoopTaskExecutionContext)); } else if (SqoopJobType.CUSTOM.getDescp().equals(sqoopParameters.getJobType())) { - sqoopScripts = sqoopParameters.getCustomShell().replaceAll("\\r\\n", "\n"); + sqoopScripts = sqoopParameters.getCustomShell().replaceAll("\\r\\n", System.lineSeparator()); } return sqoopScripts;