pan3793 commented on code in PR #51775:
URL: https://github.com/apache/spark/pull/51775#discussion_r2250836125


##########
common/utils/src/main/java/org/apache/spark/internal/SparkLogger.java:
##########
@@ -65,8 +66,10 @@
  * you can define `custom LogKey` and use it in `java` code as follows:
  * <p>
  *
- * // To add a `custom LogKey`, implement `LogKey`
- * public static class CUSTOM_LOG_KEY implements LogKey { }

Review Comment:
   @gengliangwang it's binary compatible.
   
   I created a demo project to verify it.
   
   Build against Spark 4.0.0
   ```
   git clone https://github.com/pan3793/SPARK-53064.git
   cd SPARK-53064
   ./mvnw clean install
   ```
   
   Test on Spark 4.0.0 (of course works)
   ```
   spark-4.0.0-bin-hadoop3/bin/spark-submit --class io.github.pan3793.Main 
--conf spark.log.structuredLogging.enabled=true target/SPARK-53064-1.0.jar
   ```
   Test on this PR (success if spark.log.structuredLogging.enabled is false, 
but fail when it's true)
   ```
   spark-4.1.0-SNAPSHOT-bin-SPARK-53064/bin/spark-submit --class 
io.github.pan3793.Main --conf spark.log.structuredLogging.enabled=true 
target/SPARK-53064-1.0.jar
   ```
   ```
   Exception in thread "main" java.lang.AbstractMethodError: Receiver class 
io.github.pan3793.JavaCustomLogKeys$CUSTOM_LOG_KEY does not define or inherit 
an implementation of the resolved method 'abstract java.lang.String name()' of 
interface org.apache.spark.internal.LogKey.
           at 
org.apache.spark.internal.SparkLogger.withLogContext(SparkLogger.java:229)
           at org.apache.spark.internal.SparkLogger.info(SparkLogger.java:158)
           at io.github.pan3793.Main.main(Main.java:13)
           at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
           at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.base/java.lang.reflect.Method.invoke(Method.java:569)
           at 
org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
           at 
org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:1026)
           at 
org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:203)
           at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:226)
           at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:95)
           at 
org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1131)
           at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1140)
           at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
   ```



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to