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

He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-connectors-kafka.git


The following commit(s) were added to refs/heads/main by this push:
     new c3e0f67a fix: fix compilation warnings across all Scala versions (#590)
c3e0f67a is described below

commit c3e0f67a81f3502b78fddac7d733c7c6820aeda2
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Mon Jul 6 10:15:36 2026 +0800

    fix: fix compilation warnings across all Scala versions (#590)
    
    Motivation:
    Java unchecked conversion warnings when compiling Java test classes
    that extend KafkaTestKitClass (which implements the KafkaTestKit trait).
    The private lazy val adminDefaults in the trait generated a mangled
    accessor method on the interface with an erased return type
    (java.util.Map), causing javac to warn about unchecked conversion
    to java.util.Map<String, Object>. This affected 9 Java test files.
    
    Modification:
    Moved the adminDefaults map creation from a private lazy val in the
    KafkaTestKit trait to a private[internal] method in a new
    KafkaTestKit companion object. This eliminates the mangled interface
    method that triggered the Java compiler warnings.
    
    Result:
    Clean compilation with zero warnings across all Scala versions.
    
    Tests:
    sbt +test:compile - all versions pass with no warnings
    
    References:
    None - code quality improvement
---
 .../pekko/kafka/testkit/internal/KafkaTestKit.scala      | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/testkit/src/main/scala/org/apache/pekko/kafka/testkit/internal/KafkaTestKit.scala
 
b/testkit/src/main/scala/org/apache/pekko/kafka/testkit/internal/KafkaTestKit.scala
index d152d1e4..72669f2d 100644
--- 
a/testkit/src/main/scala/org/apache/pekko/kafka/testkit/internal/KafkaTestKit.scala
+++ 
b/testkit/src/main/scala/org/apache/pekko/kafka/testkit/internal/KafkaTestKit.scala
@@ -94,12 +94,6 @@ trait KafkaTestKit {
 
   val settings = KafkaTestkitSettings(system)
 
-  private lazy val adminDefaults: java.util.Map[String, AnyRef] = {
-    val config = new java.util.HashMap[String, AnyRef]()
-    config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers)
-    config
-  }
-
   private var adminClientVar: Admin = null
 
   /**
@@ -119,7 +113,7 @@ trait KafkaTestKit {
    */
   def setUpAdminClient(): Unit =
     if (adminClientVar == null) {
-      adminClientVar = Admin.create(adminDefaults)
+      adminClientVar = 
Admin.create(KafkaTestKit.adminDefaultsMap(bootstrapServers))
     }
 
   /**
@@ -199,6 +193,14 @@ trait KafkaTestKit {
   }
 }
 
+object KafkaTestKit {
+  private[internal] def adminDefaultsMap(bootstrapServers: String): 
java.util.Map[String, AnyRef] = {
+    val config = new java.util.HashMap[String, AnyRef]()
+    config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers)
+    config
+  }
+}
+
 abstract class KafkaTestKitClass(override val system: ActorSystem, override 
val bootstrapServers: String)
     extends KafkaTestKit
 


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

Reply via email to