Skip to content

Commit

Permalink
[MINOR] Use putAll to populate Properties
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
tedyu authored and HyukjinKwon committed Dec 1, 2024
1 parent faf74ad commit b45e3c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,7 @@ class KafkaTestUtils(
props.put("sasl.enabled.mechanisms", "GSSAPI,SCRAM-SHA-512")
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ object HiveScriptIOSchema extends HiveInspectors {
propsMap = propsMap + (serdeConstants.LIST_COLUMN_TYPES -> columnTypesNames)

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

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

0 comments on commit b45e3c0

Please sign in to comment.