[ 
https://issues.apache.org/jira/browse/SPARK-47455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yang Jie reassigned SPARK-47455:
--------------------------------

    Assignee: Yang Jie

> 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, 4.0.0, 3.5.1
>            Reporter: Yang Jie
>            Assignee: Yang Jie
>            Priority: Minor
>              Labels: pull-request-available
>
> [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: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to