Skip to content
Permalink
Browse files
[FLINK-27754][shell] Add stderr when singular flink-dist*.jar cannot …
…be resolved for config.sh.
  • Loading branch information
rudikershaw authored and dannycranmer committed May 24, 2022
1 parent 8cbb42a commit d891509ab78acf7c3dc1000ef9d55e9d121e1a45
Showing 2 changed files with 18 additions and 8 deletions.
@@ -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`.
@@ -31,25 +31,35 @@ 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

echo "$FLINK_CLASSPATH""$FLINK_DIST"
}

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

0 comments on commit d891509

Please sign in to comment.