Skip to content

Commit b45e3c0

Browse files
tedyuHyukjinKwon
authored andcommitted
[MINOR] Use putAll to populate Properties
### What changes were proposed in this pull request? This PR uses the `putAll` method of `Properties` class in place of `put`. ### Why are the changes needed? In Scala 2.13, scala/bug#10418 has been fixed. So we can avoid the workaround. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? There is no change in functionality. Existing tests suffice. ### Was this patch authored or co-authored using generative AI tooling? No Closes #48993 from tedyu/put-all. Authored-by: Zhihong Yu <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent faf74ad commit b45e3c0

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,7 @@ class KafkaTestUtils(
504504
props.put("sasl.enabled.mechanisms", "GSSAPI,SCRAM-SHA-512")
505505
}
506506

507-
// Can not use properties.putAll(propsMap.asJava) in scala-2.12
508-
// See https://github.com/scala/bug/issues/10418
509-
withBrokerProps.foreach { case (k, v) => props.put(k, v) }
507+
props.putAll(withBrokerProps.asJava)
510508
props
511509
}
512510

sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ object HiveScriptIOSchema extends HiveInspectors {
283283
propsMap = propsMap + (serdeConstants.LIST_COLUMN_TYPES -> columnTypesNames)
284284

285285
val properties = new Properties()
286-
// Can not use properties.putAll(propsMap.asJava) in scala-2.12
287-
// See https://github.com/scala/bug/issues/10418
288-
propsMap.foreach { case (k, v) => properties.put(k, v) }
286+
properties.putAll(propsMap.asJava)
289287
serde.initialize(null, properties)
290288

291289
serde
@@ -299,9 +297,7 @@ object HiveScriptIOSchema extends HiveInspectors {
299297
val instance = Utils.classForName[RecordReader](klass).getConstructor().
300298
newInstance()
301299
val props = new Properties()
302-
// Can not use props.putAll(outputSerdeProps.toMap.asJava) in scala-2.12
303-
// See https://github.com/scala/bug/issues/10418
304-
ioschema.outputSerdeProps.toMap.foreach { case (k, v) => props.put(k, v) }
300+
props.putAll(ioschema.outputSerdeProps.toMap.asJava)
305301
instance.initialize(inputStream, conf, props)
306302
instance
307303
}

0 commit comments

Comments
 (0)