flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ches...@apache.org
Subject [1/3] flink git commit: [FLINK-8108][py] Fix bounds check
Date Mon, 20 Nov 2017 14:44:25 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.4 d0ea9d951 -> ee4420f4b


[FLINK-8108][py] Fix bounds check


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

Branch: refs/heads/release-1.4
Commit: 8eadda357c3739af84070cec5a8c227b55b04390
Parents: d0ea9d9
Author: zentol <chesnay@apache.org>
Authored: Mon Nov 20 12:57:43 2017 +0100
Committer: zentol <chesnay@apache.org>
Committed: Mon Nov 20 15:44:03 2017 +0100

----------------------------------------------------------------------
 .../org/apache/flink/python/api/PythonPlanBinder.java     |  9 ++++-----
 .../org/apache/flink/python/api/PythonPlanBinderTest.java | 10 ++++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/8eadda35/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
b/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
index 810c8cd..b7adde1 100644
--- a/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
+++ b/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
@@ -91,11 +91,6 @@ public class PythonPlanBinder {
 	 * @throws Exception
 	 */
 	public static void main(String[] args) throws Exception {
-		if (args.length < 2) {
-			System.out.println("Usage: ./bin/pyflink<2/3>.[sh/bat] <pathToScript>[ <pathToPackage1>[
<pathToPackageX]][ - <parameter1>[ <parameterX>]]");
-			return;
-		}
-
 		Configuration globalConfig = GlobalConfiguration.loadConfiguration();
 		PythonPlanBinder binder = new PythonPlanBinder(globalConfig);
 		binder.runPlan(args);
@@ -126,6 +121,10 @@ public class PythonPlanBinder {
 	}
 
 	void runPlan(String[] args) throws Exception {
+		if (args.length < 1) {
+			throw new IllegalArgumentException("Missing script file argument. Usage: ./bin/pyflink.[sh/bat]
<pathToScript>[ <pathToPackage1>[ <pathToPackageX]][ - <parameter1>[
<parameterX>]]");
+		}
+
 		int split = 0;
 		for (int x = 0; x < args.length; x++) {
 			if (args[x].equals("-")) {

http://git-wip-us.apache.org/repos/asf/flink/blob/8eadda35/flink-libraries/flink-python/src/test/java/org/apache/flink/python/api/PythonPlanBinderTest.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-python/src/test/java/org/apache/flink/python/api/PythonPlanBinderTest.java
b/flink-libraries/flink-python/src/test/java/org/apache/flink/python/api/PythonPlanBinderTest.java
index 2a19a5f..9e63091 100644
--- a/flink-libraries/flink-python/src/test/java/org/apache/flink/python/api/PythonPlanBinderTest.java
+++ b/flink-libraries/flink-python/src/test/java/org/apache/flink/python/api/PythonPlanBinderTest.java
@@ -118,6 +118,7 @@ public class PythonPlanBinderTest extends JavaProgramTestBase {
 
 	@Override
 	protected void testProgram() throws Exception {
+		testBoundCheck();
 		String utils = findUtilsFile();
 		String python2 = getPython2Path();
 		if (python2 != null) {
@@ -136,4 +137,13 @@ public class PythonPlanBinderTest extends JavaProgramTestBase {
 			}
 		}
 	}
+
+	private void testBoundCheck() throws Exception {
+		log.info("Running testBoundCheck.");
+		try {
+			new PythonPlanBinder(new Configuration()).runPlan(new String[0]);
+		} catch (IllegalArgumentException expected) {
+			// we expect this exception to be thrown since no argument was passed
+		}
+	}
 }


Mime
View raw message