This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new dd6525acd927 [SPARK-53023][SQL] Remove `commons-io` dependency from `sql/api` module dd6525acd927 is described below commit dd6525acd927861bac5b7ec0f730c285feae01fb Author: Dongjoon Hyun <dongj...@apache.org> AuthorDate: Wed Jul 30 15:57:26 2025 -0700 [SPARK-53023][SQL] Remove `commons-io` dependency from `sql/api` module ### What changes were proposed in this pull request? This PR aims to remove `commons-io` dependency from `sql/api` module. In addition, this PR adds a new Scalastyle to ban `org.apache.commons.io.FileUtils.readFileToByteArray` in favor of Java's native `Files.readAllBytes` API. ```scala - FileUtils.readFileToByteArray(new File(filePath)) + Files.readAllBytes(new File(filePath).toPath()) ``` ### Why are the changes needed? To reduce `sql/api` module dependency burden. ### Does this PR introduce _any_ user-facing change? No behavior change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #51729 from dongjoon-hyun/SPARK-53023. Authored-by: Dongjoon Hyun <dongj...@apache.org> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- scalastyle-config.xml | 5 +++++ sql/api/pom.xml | 4 ---- .../src/main/scala/org/apache/spark/sql/util/ProtobufUtils.scala | 6 ++---- sql/connect/client/jvm/pom.xml | 5 +++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scalastyle-config.xml b/scalastyle-config.xml index d9f25812081b..bd7c7ccb6b45 100644 --- a/scalastyle-config.xml +++ b/scalastyle-config.xml @@ -282,6 +282,11 @@ This file is divided into 3 sections: scala.jdk.CollectionConverters._ and use .asScala / .asJava methods</customMessage> </check> + <check customId="readFileToByteArray" level="error" class="org.scalastyle.file.RegexChecker" enabled="true"> + <parameters><parameter name="regex">FileUtils\.readFileToByteArray</parameter></parameters> + <customMessage>Use java.nio.file.Files.readAllBytes</customMessage> + </check> + <check customId="commonslang2" level="error" class="org.scalastyle.file.RegexChecker" enabled="true"> <parameters><parameter name="regex">org\.apache\.commons\.lang\.</parameter></parameters> <customMessage>Use Commons Lang 3 classes (package org.apache.commons.lang3.*) instead diff --git a/sql/api/pom.xml b/sql/api/pom.xml index 0a732b8a8b31..184d39c4b8ea 100644 --- a/sql/api/pom.xml +++ b/sql/api/pom.xml @@ -64,10 +64,6 @@ <version>${project.version}</version> <scope>compile</scope> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> diff --git a/sql/api/src/main/scala/org/apache/spark/sql/util/ProtobufUtils.scala b/sql/api/src/main/scala/org/apache/spark/sql/util/ProtobufUtils.scala index 11f35ceb060c..be56e3cf1313 100644 --- a/sql/api/src/main/scala/org/apache/spark/sql/util/ProtobufUtils.scala +++ b/sql/api/src/main/scala/org/apache/spark/sql/util/ProtobufUtils.scala @@ -18,18 +18,16 @@ package org.apache.spark.sql.util import java.io.{File, FileNotFoundException} -import java.nio.file.NoSuchFileException +import java.nio.file.{Files, NoSuchFileException} import scala.util.control.NonFatal -import org.apache.commons.io.FileUtils - import org.apache.spark.sql.errors.CompilationErrors object ProtobufUtils { def readDescriptorFileContent(filePath: String): Array[Byte] = { try { - FileUtils.readFileToByteArray(new File(filePath)) + Files.readAllBytes(new File(filePath).toPath()) } catch { case ex: FileNotFoundException => throw CompilationErrors.cannotFindDescriptorFileError(filePath, ex) diff --git a/sql/connect/client/jvm/pom.xml b/sql/connect/client/jvm/pom.xml index ee4f7b3483e6..ea9073057031 100644 --- a/sql/connect/client/jvm/pom.xml +++ b/sql/connect/client/jvm/pom.xml @@ -107,6 +107,11 @@ <type>test-jar</type> <scope>test</scope> </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.scalacheck</groupId> <artifactId>scalacheck_${scala.binary.version}</artifactId> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org