Skip to content

Commit

Permalink
[FLINK-27754][shell] Add stderr when singular flink-dist*.jar cannot …
Browse files Browse the repository at this point in the history
…be resolved for config.sh.
  • Loading branch information
rudikershaw authored and dannycranmer committed May 24, 2022
1 parent 8cbb42a commit d891509
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
24 changes: 17 additions & 7 deletions flink-dist/src/main/flink-bin/bin/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d891509

Please sign in to comment.