Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions vagrant/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,35 @@ fetch_jdk_tgz() {

if [ ! -e $path ]; then
mkdir -p $(dirname $path)
curl --retry 5 -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk-${jdk_version}.tar.gz" -o $path
curl --retry 5 -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk/jdk-${jdk_version}.tar.gz" -o $path
fi
}

JDK_MAJOR="${JDK_MAJOR:-17}"
JDK_FULL="${JDK_FULL:-17-linux-x64}"
# Validate JDK_MAJOR - must be a version number (e.g., 17, 25.0.1), default to 17 if empty or invalid
if [[ -z "$JDK_MAJOR" ]]; then
JDK_MAJOR="17"
elif [[ ! "$JDK_MAJOR" =~ ^[0-9]+(u[0-9]+|(\.[0-9]+)+)?$ ]]; then
echo "WARNING: Invalid JDK_MAJOR format '$JDK_MAJOR'. Expected format: 17, 21.0.1, 25.0.2. Defaulting to 17."
JDK_MAJOR="17"
fi

# Validate JDK_ARCH - default to x64 if empty or invalid
if [[ -z "$JDK_ARCH" ]]; then
JDK_ARCH="x64"
elif [[ ! "$JDK_ARCH" =~ ^(x64|aarch64)$ ]]; then
echo "WARNING: Invalid JDK_ARCH format '$JDK_ARCH'. Expected: x64 or aarch64. Defaulting to x64."
JDK_ARCH="x64"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we either throw an exception or log a warning if the format is invalid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to avoid breaking any existing workflows, so I don’t think we should throw an exception here. Defaulting to this behavior makes sense, but I can add a warning log to flag the invalid format.

fi

# Use JDK_FULL if provided and valid, otherwise construct from JDK_MAJOR and JDK_ARCH
if [[ -z "$JDK_FULL" ]]; then
JDK_FULL="${JDK_MAJOR}-linux-${JDK_ARCH}"
elif [[ ! "$JDK_FULL" =~ ^[0-9]+(u[0-9]+|(\.[0-9]+)+)?-linux-(x64|aarch64)$ ]]; then
echo "WARNING: Invalid JDK_FULL format '$JDK_FULL'. Constructing from JDK_MAJOR and JDK_ARCH."
JDK_FULL="${JDK_MAJOR}-linux-${JDK_ARCH}"
fi

echo "JDK_MAJOR=$JDK_MAJOR JDK_ARCH=$JDK_ARCH JDK_FULL=$JDK_FULL"

if [ -z `which javac` ]; then
apt-get -y update
Expand Down