From 3b7081856729bcc8b584c08d1eec6b231303d812 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 11:34:16 -0500 Subject: [PATCH 1/7] Add support for errorprone 2.24.1 static analysis tool and Github Action to check for issues reported --- .github/workflows/errorprone.yml | 93 ++++++++++++++++++++++++++++++++ pom.xml | 19 +++++-- 2 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/errorprone.yml diff --git a/.github/workflows/errorprone.yml b/.github/workflows/errorprone.yml new file mode 100644 index 000000000000..dc391c62c917 --- /dev/null +++ b/.github/workflows/errorprone.yml @@ -0,0 +1,93 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Error Prone Analysis + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + errorprone: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'adopt' + architecture: x64 + cache: maven + + - name: Run Error Prone Static Analysis (Strict Mode) + run: | + echo "::group::Error Prone Analysis" + # Temporarily remove -XepAllErrorsAsWarnings to run in strict mode + sed -i 's/-Xplugin:ErrorProne -XepAllErrorsAsWarnings/-Xplugin:ErrorProne/g' pom.xml + mvn clean compile -DskipTests -T$(nproc) 2>&1 | tee errorprone.log + BUILD_RESULT=$? + echo "::endgroup::" + exit $BUILD_RESULT + continue-on-error: true + + - name: Check for Error Prone Issues + id: check-errors + run: | + if grep -q "error: \[" errorprone.log; then + echo "has_errors=true" >> $GITHUB_OUTPUT + echo "::error::Error Prone found issues in the code" + echo "" + echo "=== Error Prone Issues Found ===" + grep -B 2 "error: \[" errorprone.log | head -50 + echo "" + + # Create job summary + echo "## ⚠️ Error Prone Analysis Failed" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error Prone static analysis detected issues in this PR." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Issues Found (first 50):" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + grep -B 2 "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "See the [Error Prone documentation](https://errorprone.info/) for details on each bug pattern." >> $GITHUB_STEP_SUMMARY + else + echo "has_errors=false" >> $GITHUB_OUTPUT + echo "✅ No Error Prone issues found" + + # Create success summary + echo "## ✅ Error Prone Analysis Passed" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "No issues detected by Error Prone static analysis." >> $GITHUB_STEP_SUMMARY + fi + + - name: Fail if errors found + if: steps.check-errors.outputs.has_errors == 'true' + run: exit 1 + diff --git a/pom.xml b/pom.xml index 6985108302df..fc31667b963a 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,7 @@ 2.22.2 4.4.1 3.2.0 + 2.24.1 2.19.0 @@ -1094,15 +1095,25 @@ ${cs.jdk.version} ${cs.jdk.version} - true - 128m - 512m + UTF-8 -XDignore.symbol.file=true --add-opens=java.base/java.lang=ALL-UNNAMED --add-exports=java.base/sun.security.x509=ALL-UNNAMED --add-exports=java.base/sun.security.provider=ALL-UNNAMED + -XDcompilePolicy=simple + -Xplugin:ErrorProne -XepAllErrorsAsWarnings + + + com.google.errorprone + error_prone_core + ${cs.errorprone.version} + + + true + 128m + 512m @@ -1452,4 +1463,4 @@ - + \ No newline at end of file From d32ca11747c0d21a9e4ace5508ac2e806f59ea76 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 11:42:25 -0500 Subject: [PATCH 2/7] add newline --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc31667b963a..3309a97a6b82 100644 --- a/pom.xml +++ b/pom.xml @@ -1463,4 +1463,4 @@ - \ No newline at end of file + From 1720ebb23dca63f431eab1ce23528bffdecb6dd4 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 11:46:18 -0500 Subject: [PATCH 3/7] temporarily add 4.20 and PR branch to gha --- .github/workflows/errorprone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/errorprone.yml b/.github/workflows/errorprone.yml index dc391c62c917..f1d465f2f69e 100644 --- a/.github/workflows/errorprone.yml +++ b/.github/workflows/errorprone.yml @@ -19,9 +19,9 @@ name: Error Prone Analysis on: push: - branches: [ main ] + branches: [ main, add-errorprone ] pull_request: - branches: [ main ] + branches: [ main, '4.20' ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} From a713305e2156ef58503836d19197b625d6b73b46 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 11:48:51 -0500 Subject: [PATCH 4/7] omit errorprone spellcheck --- .github/linters/codespell.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/linters/codespell.txt b/.github/linters/codespell.txt index 37b3e6de1cbe..8b05c4ef621f 100644 --- a/.github/linters/codespell.txt +++ b/.github/linters/codespell.txt @@ -188,6 +188,7 @@ environmnet equivalant erro erronous +errorprone everthing everytime excetion From a52eadc964b8317f2711a02eb5942e09d9fe683a Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 12:05:19 -0500 Subject: [PATCH 5/7] Update gha --- .github/workflows/errorprone.yml | 55 ++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/.github/workflows/errorprone.yml b/.github/workflows/errorprone.yml index f1d465f2f69e..ce0a3d2b4f25 100644 --- a/.github/workflows/errorprone.yml +++ b/.github/workflows/errorprone.yml @@ -45,43 +45,72 @@ jobs: cache: maven - name: Run Error Prone Static Analysis (Strict Mode) + id: errorprone run: | echo "::group::Error Prone Analysis" # Temporarily remove -XepAllErrorsAsWarnings to run in strict mode sed -i 's/-Xplugin:ErrorProne -XepAllErrorsAsWarnings/-Xplugin:ErrorProne/g' pom.xml - mvn clean compile -DskipTests -T$(nproc) 2>&1 | tee errorprone.log - BUILD_RESULT=$? + + set -o pipefail + + # Use -fae (fail-at-end) to build all modules and report failures at the end + mvn -fae clean test-compile -T$(nproc) 2>&1 | tee errorprone.log + MVN_EXIT=${PIPESTATUS[0]} + + echo "mvn_exit=${MVN_EXIT}" >> $GITHUB_OUTPUT echo "::endgroup::" - exit $BUILD_RESULT + + exit 0 continue-on-error: true - name: Check for Error Prone Issues id: check-errors run: | + HAS_ERRORS=false + + if [ "${{ steps.errorprone.outputs.mvn_exit }}" != "0" ]; then + HAS_ERRORS=true + echo "Maven build exited with code ${{ steps.errorprone.outputs.mvn_exit }}" + fi + if grep -q "error: \[" errorprone.log; then + HAS_ERRORS=true + fi + + if grep -q "^\[ERROR\]" errorprone.log; then + HAS_ERRORS=true + fi + + if [ "$HAS_ERRORS" = "true" ]; then echo "has_errors=true" >> $GITHUB_OUTPUT - echo "::error::Error Prone found issues in the code" + echo "::error::Error Prone and/or compilation issues found in the code" + echo "" + echo "=== Error Prone Issues ===" + grep -n "error: \[" errorprone.log | head -50 || echo "No Error Prone specific issues" echo "" - echo "=== Error Prone Issues Found ===" - grep -B 2 "error: \[" errorprone.log | head -50 + echo "=== Maven [ERROR] Lines ===" + grep -n "^\[ERROR\]" errorprone.log | head -50 || echo "No Maven errors" echo "" - - # Create job summary + echo "## ⚠️ Error Prone Analysis Failed" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "Error Prone static analysis detected issues in this PR." >> $GITHUB_STEP_SUMMARY + echo "Error Prone static analysis and/or compilation detected issues in this PR." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "### Issues Found (first 50):" >> $GITHUB_STEP_SUMMARY + echo "### Error Prone Issues (first 50):" >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY - grep -B 2 "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY + grep -n "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY || echo "None" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Maven Compilation Errors (first 50):" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + grep -n "^\[ERROR\]" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY || echo "None" >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "See the [Error Prone documentation](https://errorprone.info/) for details on each bug pattern." >> $GITHUB_STEP_SUMMARY else echo "has_errors=false" >> $GITHUB_OUTPUT echo "✅ No Error Prone issues found" - - # Create success summary + echo "## ✅ Error Prone Analysis Passed" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "No issues detected by Error Prone static analysis." >> $GITHUB_STEP_SUMMARY From 238d07276f326afed9aaabdb4747da3d3af8f446 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 12:09:54 -0500 Subject: [PATCH 6/7] fix newline and whitespace issues --- .github/workflows/errorprone.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/errorprone.yml b/.github/workflows/errorprone.yml index ce0a3d2b4f25..da9578bd8346 100644 --- a/.github/workflows/errorprone.yml +++ b/.github/workflows/errorprone.yml @@ -52,7 +52,7 @@ jobs: sed -i 's/-Xplugin:ErrorProne -XepAllErrorsAsWarnings/-Xplugin:ErrorProne/g' pom.xml set -o pipefail - + # Use -fae (fail-at-end) to build all modules and report failures at the end mvn -fae clean test-compile -T$(nproc) 2>&1 | tee errorprone.log MVN_EXIT=${PIPESTATUS[0]} @@ -80,7 +80,7 @@ jobs: if grep -q "^\[ERROR\]" errorprone.log; then HAS_ERRORS=true fi - + if [ "$HAS_ERRORS" = "true" ]; then echo "has_errors=true" >> $GITHUB_OUTPUT echo "::error::Error Prone and/or compilation issues found in the code" @@ -119,4 +119,3 @@ jobs: - name: Fail if errors found if: steps.check-errors.outputs.has_errors == 'true' run: exit 1 - From 43345d4ab86dc86dc9c96eef194f0132ad47dcd7 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 14 Jan 2026 12:23:39 -0500 Subject: [PATCH 7/7] Update gha --- .github/workflows/errorprone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/errorprone.yml b/.github/workflows/errorprone.yml index da9578bd8346..a8aeda746b06 100644 --- a/.github/workflows/errorprone.yml +++ b/.github/workflows/errorprone.yml @@ -54,7 +54,8 @@ jobs: set -o pipefail # Use -fae (fail-at-end) to build all modules and report failures at the end - mvn -fae clean test-compile -T$(nproc) 2>&1 | tee errorprone.log + # Run 'test' phase to compile and test all modules + mvn -fae clean test -T$(nproc) 2>&1 | tee errorprone.log MVN_EXIT=${PIPESTATUS[0]} echo "mvn_exit=${MVN_EXIT}" >> $GITHUB_OUTPUT