Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions common/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_${scala.binary.version}</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

package org.apache.spark.util

import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path}
import java.util.{ArrayList => JList}

import scala.jdk.CollectionConverters._
import scala.reflect.runtime.universe._

import org.apache.commons.io.FileUtils
import org.scalatest.funsuite.AnyFunSuite // scalastyle:ignore funsuite

import org.apache.spark.internal.{Logging, LogKeys}
Expand Down Expand Up @@ -61,9 +59,8 @@ class LogKeySuite
private def regenerateLogKeyFile(
originalKeys: Seq[String], sortedKeys: Seq[String]): Unit = {
if (originalKeys != sortedKeys) {
val logKeyFile = logKeyFilePath.toFile
logInfo(s"Regenerating the file $logKeyFile")
val originalContents = FileUtils.readLines(logKeyFile, StandardCharsets.UTF_8)
logInfo(s"Regenerating the file $logKeyFilePath")
val originalContents = Files.readAllLines(logKeyFilePath)
val sortedContents = new JList[String]()
var firstMatch = false
originalContents.asScala.foreach { line =>
Expand All @@ -78,8 +75,8 @@ class LogKeySuite
sortedContents.add(line)
}
}
Files.delete(logKeyFile.toPath)
FileUtils.writeLines(logKeyFile, StandardCharsets.UTF_8.name(), sortedContents)
Files.delete(logKeyFilePath)
Files.write(logKeyFilePath, sortedContents)
}
}

Expand Down
10 changes: 10 additions & 0 deletions scalastyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@ This file is divided into 3 sections:
scala.jdk.CollectionConverters._ and use .asScala / .asJava methods</customMessage>
</check>

<check customId="readLines" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter name="regex">FileUtils\.readLines</parameter></parameters>
<customMessage>Use Files.readAllLines instead.</customMessage>
</check>

<check customId="writeLines" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter name="regex">FileUtils\.writeLines</parameter></parameters>
<customMessage>Use Files.write instead.</customMessage>
</check>

<check customId="deleteRecursively" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter name="regex">FileUtils\.deleteDirectory</parameter></parameters>
<customMessage>Use deleteRecursively of SparkFileUtils or Utils</customMessage>
Expand Down