[
https://issues.apache.org/jira/browse/SPARK-47455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dongjoon Hyun closed SPARK-47455.
---------------------------------
> Fix Resource Handling of `scalaStyleOnCompileConfig` in SparkBuild.scala
> ------------------------------------------------------------------------
>
> Key: SPARK-47455
> URL: https://issues.apache.org/jira/browse/SPARK-47455
> Project: Spark
> Issue Type: Bug
> Components: Project Infra
> Affects Versions: 3.4.2, 3.5.1, 4.0.0
> Reporter: Yang Jie
> Assignee: Yang Jie
> Priority: Minor
> Labels: pull-request-available
> Fix For: 3.5.2, 3.4.3, 4.0.0
>
>
> [https://github.com/apache/spark/blob/e01ed0da22f24204fe23143032ff39be7f4b56af/project/SparkBuild.scala#L157-L173]
>
> {code:java}
> val scalaStyleOnCompileConfig: String = {
> val in = "scalastyle-config.xml"
> val out = "scalastyle-on-compile.generated.xml"
> val replacements = Map(
> """customId="println" level="error"""" -> """customId="println"
> level="warn""""
> )
> var contents = Source.fromFile(in).getLines.mkString("\n")
> for ((k, v) <- replacements) {
> require(contents.contains(k), s"Could not rewrite '$k' in original
> scalastyle config.")
> contents = contents.replace(k, v)
> }
> new PrintWriter(out) {
> write(contents)
> close()
> }
> out
> } {code}
> `Source.fromFile(in)` opens a `BufferedSource` resource handle, but it does
> not close it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]