flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject flink git commit: [FLINK-3838] upgrade commons-cli to fix parsing of jar args
Date Sat, 25 Jun 2016 15:38:36 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.0 e208325ef -> 37bc3374a


[FLINK-3838] upgrade commons-cli to fix parsing of jar args

Jar arguments with a single '-' were not parsed correctly if options were
present. For example, in `./flink run <options> file.jar -arg value` the
jar arguments would be parsed as "arg" and "value". Interestingly, this only
happened when <options> were present.

The issue has been fixed in commons-cli 1.3.1.

A test case was added to test for regressions.

This closes #2139


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/37bc3374
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/37bc3374
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/37bc3374

Branch: refs/heads/release-1.0
Commit: 37bc3374a03a0443ad838d92303bf28179d3b869
Parents: e208325
Author: Maximilian Michels <mxm@apache.org>
Authored: Tue Jun 21 09:32:56 2016 +0200
Committer: Maximilian Michels <mxm@apache.org>
Committed: Sat Jun 25 17:39:34 2016 +0200

----------------------------------------------------------------------
 .../apache/flink/client/cli/CliFrontendParser.java   | 15 +++++++--------
 .../org/apache/flink/client/CliFrontendRunTest.java  | 12 ++++++++++++
 pom.xml                                              |  2 +-
 3 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/37bc3374/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
index 2ac53d2..3c94c2d 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
@@ -18,12 +18,11 @@
 package org.apache.flink.client.cli;
 
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-
 import org.apache.flink.client.CliFrontend;
 import org.apache.flink.client.FlinkYarnSessionCli;
 
@@ -313,7 +312,7 @@ public class CliFrontendParser {
 
 	public static RunOptions parseRunCommand(String[] args) throws CliArgsException {
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(RUN_OPTIONS, args, true);
 			return new RunOptions(line);
 		}
@@ -324,7 +323,7 @@ public class CliFrontendParser {
 
 	public static ListOptions parseListCommand(String[] args) throws CliArgsException {
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(LIST_OPTIONS, args, false);
 			return new ListOptions(line);
 		}
@@ -335,7 +334,7 @@ public class CliFrontendParser {
 
 	public static CancelOptions parseCancelCommand(String[] args) throws CliArgsException {
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(CANCEL_OPTIONS, args, false);
 			return new CancelOptions(line);
 		}
@@ -346,7 +345,7 @@ public class CliFrontendParser {
 
 	public static StopOptions parseStopCommand(String[] args) throws CliArgsException {
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(STOP_OPTIONS, args, false);
 			return new StopOptions(line);
 		} catch (ParseException e) {
@@ -356,7 +355,7 @@ public class CliFrontendParser {
 
 	public static SavepointOptions parseSavepointCommand(String[] args) throws CliArgsException
{
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(SAVEPOINT_OPTIONS, args, false);
 			return new SavepointOptions(line);
 		}
@@ -367,7 +366,7 @@ public class CliFrontendParser {
 
 	public static InfoOptions parseInfoCommand(String[] args) throws CliArgsException {
 		try {
-			PosixParser parser = new PosixParser();
+			DefaultParser parser = new DefaultParser();
 			CommandLine line = parser.parse(INFO_OPTIONS, args, true);
 			return new InfoOptions(line);
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/37bc3374/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java b/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java
index 56173bd..b3e2f17 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java
@@ -102,6 +102,18 @@ public class CliFrontendRunTest {
 				RunOptions options = CliFrontendParser.parseRunCommand(parameters);
 				assertEquals("expectedSavepointPath", options.getSavepointPath());
 			}
+
+			// test jar arguments
+			{
+				String[] parameters =
+					{"-m", "localhost:6123", getTestJarPath(), "-arg1", "value1", "justavalue", "--arg2",
"value2"};
+				RunOptions options = CliFrontendParser.parseRunCommand(parameters);
+				assertEquals("-arg1", options.getProgramArgs()[0]);
+				assertEquals("value1", options.getProgramArgs()[1]);
+				assertEquals("justavalue", options.getProgramArgs()[2]);
+				assertEquals("--arg2", options.getProgramArgs()[3]);
+				assertEquals("value2", options.getProgramArgs()[4]);
+			}
 		}
 		catch (Exception e) {
 			e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/flink/blob/37bc3374/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 670dbb2..ad858cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -207,7 +207,7 @@ under the License.
 			<dependency>
 				<groupId>commons-cli</groupId>
 				<artifactId>commons-cli</artifactId>
-				<version>1.2</version>
+				<version>1.3.1</version>
 			</dependency>
 
 			<dependency>


Mime
View raw message