This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new bdbbbbe  [SPARK-55470] Add a `Checkstyle` rule to enforce symbolic 
placeholder for logging
bdbbbbe is described below

commit bdbbbbe5725e619c6bdd79ddc7bc8c11ee156c7c
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Tue Feb 10 07:59:36 2026 -0800

    [SPARK-55470] Add a `Checkstyle` rule to enforce symbolic placeholder for 
logging
    
    ### What changes were proposed in this pull request?
    
    This PR aims to add a `Checkstyle` rule to enforce symbolic placeholder for 
logging.
    
    ### Why are the changes needed?
    
    To enforce the best practice for logging code.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No behavior change.
    
    ### How was this patch tested?
    
    Pass the CIs (including Checkstyle)
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: `Opus 4.5` on `Claude Code`
    
    Closes #495 from dongjoon-hyun/SPARK-55470.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 config/checkstyle/checkstyle.xml                                     | 5 +++++
 .../src/main/java/org/apache/spark/k8s/operator/SparkOperator.java   | 2 +-
 .../main/java/org/apache/spark/k8s/operator/probe/ProbeService.java  | 2 +-
 .../org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java | 2 +-
 .../java/org/apache/spark/k8s/operator/utils/StatusRecorder.java     | 4 ++--
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 9f02ee6..dac1375 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -200,6 +200,11 @@
       <property name="message"
                 value="Please use the `assertThrows` method to test for 
exceptions."/>
     </module>
+    <module name="RegexpSinglelineJava">
+      <property name="format" 
value="log\.(info|debug|warn|error|trace)\(.*\+"/>
+      <property name="message"
+                value="Use symbolic placeholders for logging instead of string 
concatenation."/>
+    </module>
     <module name="IllegalImport">
       <property name="illegalPkgs" value="org.apache.commons.codec"/>
       <property name="illegalPkgs" value="org.apache.commons.collections"/>
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/SparkOperator.java 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/SparkOperator.java
index 9c600b6..b01685f 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/SparkOperator.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/SparkOperator.java
@@ -284,7 +284,7 @@ public class SparkOperator {
    */
   public static void main(String[] args) {
     log.info("Version: {}", 
SparkOperator.class.getPackage().getImplementationVersion());
-    log.info("Java Version: " + Runtime.version().toString());
+    log.info("Java Version: {}", Runtime.version().toString());
     log.info("Built-in Spark Version: {}", 
org.apache.spark.package$.MODULE$.SPARK_VERSION());
     SparkOperator sparkOperator = new SparkOperator();
     for (Operator operator : sparkOperator.registeredOperators) {
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/probe/ProbeService.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/probe/ProbeService.java
index c14b0fe..c21f4a2 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/probe/ProbeService.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/probe/ProbeService.java
@@ -72,7 +72,7 @@ public class ProbeService {
 
   /** Starts the probe service HTTP server. */
   public void start() {
-    log.info("Probe service started at " + OPERATOR_PROBE_PORT.getValue());
+    log.info("Probe service started at {}", OPERATOR_PROBE_PORT.getValue());
     server.start();
   }
 
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
index 99d09ba..92c99c4 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
@@ -206,7 +206,7 @@ public class SparkAppReconciler implements 
Reconciler<SparkApplication>, Cleaner
     LoggingUtils.TrackedMDC trackedMDC = new LoggingUtils.TrackedMDC();
     try {
       trackedMDC.set(sparkApplication);
-      log.info("Cleaning up resources for SparkApp:" + 
sparkApplication.getMetadata().getName());
+      log.info("Cleaning up resources for SparkApp: {}", 
sparkApplication.getMetadata().getName());
       SparkAppContext ctx = new SparkAppContext(sparkApplication, context, 
submissionWorker);
       List<AppReconcileStep> cleanupSteps = new ArrayList<>();
       cleanupSteps.add(new AppValidateStep());
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/utils/StatusRecorder.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/utils/StatusRecorder.java
index 87fc4a6..d7d2647 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/utils/StatusRecorder.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/utils/StatusRecorder.java
@@ -95,7 +95,7 @@ public class StatusRecorder<
 
     Exception err = null;
     long maxRetry = API_STATUS_PATCH_MAX_ATTEMPTS.getValue();
-    for (long i = 0; i < maxRetry; i++) {
+    for (long i = 1; i <= maxRetry; i++) {
       // We retry the status update maxRetry times to avoid some intermittent 
connectivity errors
       try {
         CR updated = 
client.resource(resource).lockResourceVersion().updateStatus();
@@ -103,7 +103,7 @@ public class StatusRecorder<
         err = null;
         break;
       } catch (KubernetesClientException e) {
-        log.debug("Error while patching status, retrying {}/{}...", i + 1, 
maxRetry, e);
+        log.debug("Error while patching status, retrying {}/{}...", i, 
maxRetry, e);
         
Thread.sleep(TimeUnit.SECONDS.toMillis(API_RETRY_ATTEMPT_AFTER_SECONDS.getValue()));
         err = e;
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to