joshua2519 commented on code in PR #20658:
URL: https://github.com/apache/kafka/pull/20658#discussion_r2422580343


##########
wrapper.gradle:
##########
@@ -53,6 +56,27 @@ task bootstrapWrapper() {
             sleep 5
             continue
           fi
+        else
+          # Verify checksum of existing wrapper JAR. 
+          # This prevents developers from running into incompatibility issues 
when using an outdated wrapper JAR after a Gradle upgrade.
+          # Use sha256sum or shasum, whichever is available.
+          if command -v sha256sum >/dev/null 2>&1; then
+            LOCAL_WRAPPER_JAR_CHECKSUM=\$(sha256sum "$wrapperJarPath" | awk 
'{print \$1}')
+          elif command -v shasum >/dev/null 2>&1; then
+            LOCAL_WRAPPER_JAR_CHECKSUM=\$(shasum -a 256 "$wrapperJarPath" | 
awk '{print \$1}')
+          else
+            # If no checksum tool is found, delete the JAR and re-download.
+            warn "Cannot find sha256sum or shasum to verify wrapper JAR. 
Deleting and re-downloading."
+            rm -f "$wrapperJarPath"
+            continue
+          fi
+
+          # If the local checksum does not match the required checksum, delete 
the JAR to force re-download.
+          if [ "\$LOCAL_WRAPPER_JAR_CHECKSUM" != 
"\$REQUIRED_WRAPPER_JAR_CHECKSUM" ] ; then
+            rm -f "$wrapperJarPath"
+          else
+            break

Review Comment:
   @chia7712
   The loop will break once the JAR file exists and the checksum matches.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to