This is an automated email from the ASF dual-hosted git repository.

dannycranmer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new d891509ab78 [FLINK-27754][shell] Add stderr when singular 
flink-dist*.jar cannot be resolved for config.sh.
d891509ab78 is described below

commit d891509ab78acf7c3dc1000ef9d55e9d121e1a45
Author: Rudi Kershaw <[email protected]>
AuthorDate: Fri May 13 22:07:01 2022 +0100

    [FLINK-27754][shell] Add stderr when singular flink-dist*.jar cannot be 
resolved for config.sh.
---
 README.md                                   |  2 +-
 flink-dist/src/main/flink-bin/bin/config.sh | 24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index c0cd28915e9..311b9f85642 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ Prerequisites for building Flink:
 ```
 git clone https://github.com/apache/flink.git
 cd flink
-mvn clean package -DskipTests # this will take up to 10 minutes
+./mvnw clean package -DskipTests # this will take up to 10 minutes
 ```
 
 Flink is now installed in `build-target`.
diff --git a/flink-dist/src/main/flink-bin/bin/config.sh 
b/flink-dist/src/main/flink-bin/bin/config.sh
index afb761db9e1..e8b1e2a818a 100755
--- a/flink-dist/src/main/flink-bin/bin/config.sh
+++ b/flink-dist/src/main/flink-bin/bin/config.sh
@@ -31,11 +31,16 @@ constructFlinkClassPath() {
         fi
     done < <(find "$FLINK_LIB_DIR" ! -type d -name '*.jar' -print0 | sort -z)
 
+    local FLINK_DIST_COUNT
+    FLINK_DIST_COUNT="$(echo "$FLINK_DIST" | wc -l)"
+
+    # If flink-dist*.jar cannot be resolved write error messages to stderr 
since stdout is stored
+    # as the classpath and exit function with empty classpath to force process 
failure
     if [[ "$FLINK_DIST" == "" ]]; then
-        # write error message to stderr since stdout is stored as the classpath
         (>&2 echo "[ERROR] Flink distribution jar not found in 
$FLINK_LIB_DIR.")
-
-        # exit function with empty classpath to force process failure
+        exit 1
+    elif [[ "$FLINK_DIST_COUNT" -gt 1 ]]; then
+        (>&2 echo "[ERROR] Multiple flink-dist*.jar found in $FLINK_LIB_DIR. 
Please resolve.")
         exit 1
     fi
 
@@ -43,13 +48,18 @@ constructFlinkClassPath() {
 }
 
 findFlinkDistJar() {
-    local FLINK_DIST="`find "$FLINK_LIB_DIR" -name 'flink-dist*.jar'`"
+    local FLINK_DIST
+    FLINK_DIST="$(find "$FLINK_LIB_DIR" -name 'flink-dist*.jar')"
+    local FLINK_DIST_COUNT
+    FLINK_DIST_COUNT="$(echo "$FLINK_DIST" | wc -l)"
 
+    # If flink-dist*.jar cannot be resolved write error messages to stderr 
since stdout is stored
+    # as the classpath and exit function with empty classpath to force process 
failure
     if [[ "$FLINK_DIST" == "" ]]; then
-        # write error message to stderr since stdout is stored as the classpath
         (>&2 echo "[ERROR] Flink distribution jar not found in 
$FLINK_LIB_DIR.")
-
-        # exit function with empty classpath to force process failure
+        exit 1
+    elif [[ "$FLINK_DIST_COUNT" -gt 1 ]]; then
+        (>&2 echo "[ERROR] Multiple flink-dist*.jar found in $FLINK_LIB_DIR. 
Please resolve.")
         exit 1
     fi
 

Reply via email to