This is an automated email from the ASF dual-hosted git repository.

casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new 33f38d119 feat:Scala code format alarm clear in linkis-common (#3173)
33f38d119 is described below

commit 33f38d11994e1b690d6f3f02c021c6b115ace4b2
Author: ruY <[email protected]>
AuthorDate: Sat Sep 3 14:33:41 2022 +0800

    feat:Scala code format alarm clear in linkis-common (#3173)
---
 .../org/apache/linkis/common/conf/CommonVars.scala | 12 +++---
 .../linkis/common/listener/ListenerEventBus.scala  |  6 ++-
 .../apache/linkis/common/utils/ArrayUtils.scala    |  4 +-
 .../linkis/common/utils/CodeAndRunTypeUtils.scala  | 10 +++--
 .../apache/linkis/common/utils/FileService.scala   |  2 +-
 .../apache/linkis/common/utils/ShutdownUtils.scala |  2 +-
 .../org/apache/linkis/common/utils/Utils.scala     |  4 +-
 .../org/apache/linkis/common/utils/ZipUtils.scala  | 47 +++++++++++++---------
 8 files changed, 52 insertions(+), 35 deletions(-)

diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/CommonVars.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/CommonVars.scala
index 738b08ff9..3fc4c49c6 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/CommonVars.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/CommonVars.scala
@@ -17,18 +17,20 @@
 
 package org.apache.linkis.common.conf
 
-import scala.collection.JavaConversions._
+import java.util.Properties
+
+import scala.collection.JavaConverters._
 
 case class CommonVars[T](key: String, defaultValue: T, value: T, description: 
String = null) {
   val getValue: T = BDPConfiguration.getOption(this).getOrElse(defaultValue)
 
   def getValue(properties: java.util.Map[String, String]): T = {
-    if (properties == null || !properties.containsKey(key) || 
properties.get(key) == null)
+    if (properties == null || !properties.containsKey(key) || 
properties.get(key) == null) {
       getValue
-    else BDPConfiguration.formatValue(defaultValue, 
Option(properties.get(key))).get
+    } else BDPConfiguration.formatValue(defaultValue, 
Option(properties.get(key))).get
   }
 
-  def getValue(properties: Map[String, String]): T = 
getValue(mapAsJavaMap(properties))
+  def getValue(properties: Map[String, String]): T = 
getValue(properties.asJava)
   def acquireNew: T = BDPConfiguration.getOption(this).getOrElse(defaultValue)
 }
 
@@ -42,6 +44,6 @@ object CommonVars {
 
   implicit def apply[T](key: String): CommonVars[T] = apply(key, 
null.asInstanceOf[T])
 
-  def properties = BDPConfiguration.properties
+  def properties: Properties = BDPConfiguration.properties
 
 }
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/listener/ListenerEventBus.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/listener/ListenerEventBus.scala
index 008906e2b..f42ec527e 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/listener/ListenerEventBus.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/listener/ListenerEventBus.scala
@@ -277,8 +277,9 @@ abstract class ListenerEventBus[L <: EventListener, E <: 
Event](
 
     def isRunning: Boolean = event.isDefined
 
-    def putEvent(event: E): Boolean = if (this.event.isDefined) false
-    else
+    def putEvent(event: E): Boolean = if (this.event.isDefined) {
+      false
+    } else {
       synchronized {
         if (this.event.isDefined) false
         else {
@@ -289,6 +290,7 @@ abstract class ListenerEventBus[L <: EventListener, E <: 
Event](
           true
         }
       }
+    }
 
     override def run(): Unit = {
       val threadName = Thread.currentThread().getName
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ArrayUtils.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ArrayUtils.scala
index 3a3eceaf5..ad3ab8f62 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ArrayUtils.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ArrayUtils.scala
@@ -24,7 +24,7 @@ import scala.reflect.ClassTag
 object ArrayUtils {
 
   def newArray[T](newLength: Int, clazz: Class[_ <: Array[T]]): Array[T] =
-    reflect.Array.newInstance(clazz.getComponentType, newLength) match {
+    java.lang.reflect.Array.newInstance(clazz.getComponentType, newLength) 
match {
       case destArray: Array[T] => destArray
     }
 
@@ -39,7 +39,7 @@ object ArrayUtils {
     copyArray[T](array, array.length)
 
   def copyArrayWithClass[T](array: Seq[T], clazz: Class[_ <: T]): Array[T] = {
-    val destArray = reflect.Array.newInstance(clazz, array.length) match {
+    val destArray = java.lang.reflect.Array.newInstance(clazz, array.length) 
match {
       case destArray: Array[T] => destArray
     }
     if (null == array || array.isEmpty) return destArray
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
index dbd2de0ab..9c4f552d9 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
@@ -39,19 +39,21 @@ object CodeAndRunTypeUtils {
 
   private def codeTypeAndRunTypeRelationMapParser(configV: String): 
Map[String, List[String]] = {
     val confDelimiter = ","
-    if (configV == null || "".equals(configV)) Map()
-    else
+    if (configV == null || "".equals(configV)) {
+      Map()
+    } else {
       configV
         .split(confDelimiter)
         .filter(x => x != null && !"".equals(x))
         .map(x => {
           val confArr = x.split("=>")
-          if (confArr.length == 2)
+          if (confArr.length == 2) {
             (confArr(0), for (x <- confArr(1).split("\\|").toList) yield 
x.trim)
-          else null
+          } else null
         })
         .filter(x => x != null)
         .toMap
+    }
   }
 
   def getCodeTypeAndRunTypeRelationMap: Map[String, List[String]] = {
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/FileService.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/FileService.scala
index b72d283b5..87ea5b918 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/FileService.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/FileService.scala
@@ -19,7 +19,7 @@ package org.apache.linkis.common.utils
 
 import java.io.{InputStream, OutputStream}
 
-@Deprecated
+@deprecated
 trait FileService {
 
   def getLength(path: String, user: String): Long
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ShutdownUtils.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ShutdownUtils.scala
index b9dd57b78..7fefb16ab 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ShutdownUtils.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ShutdownUtils.scala
@@ -79,7 +79,7 @@ class DefaultShutdownRunner(override val order: Int, 
runnable: Runnable) extends
     ShutdownUtils synchronized ShutdownUtils.notify()
   }
 
-  def isCompleted = completed
+  def isCompleted: Boolean = completed
 }
 
 class FunctionShutdownRunner(override val order: Int, hook: => Unit) extends 
ShutdownRunner {
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
index ddf8fb289..6a7a030fd 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
@@ -32,7 +32,7 @@ import java.util.concurrent._
 import java.util.concurrent.atomic.AtomicInteger
 
 import scala.annotation.tailrec
-import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
 import scala.concurrent.{ExecutionContext, ExecutionContextExecutorService}
 import scala.concurrent.duration.Duration
 import scala.util.control.ControlThrowable
@@ -291,7 +291,7 @@ object Utils extends Logging {
    * @return
    */
   def exec(commandLine: List[String], maxWaitTime: Long): String = {
-    val pb = new ProcessBuilder(commandLine)
+    val pb = new ProcessBuilder(commandLine.asJava)
     pb.redirectErrorStream(true)
     pb.redirectInput(ProcessBuilder.Redirect.PIPE)
     val process = pb.start
diff --git 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ZipUtils.scala
 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ZipUtils.scala
index 3ebfb4383..8396f2201 100644
--- 
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ZipUtils.scala
+++ 
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/ZipUtils.scala
@@ -24,7 +24,7 @@ import org.apache.commons.io.IOUtils
 import java.io._
 import java.util.zip.{ZipEntry, ZipInputStream, ZipOutputStream}
 
-import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
 
 object ZipUtils {
 
@@ -46,25 +46,28 @@ object ZipUtils {
     var bis: BufferedInputStream = null
     var zos: ZipOutputStream = null
     val sourcePath = new FsPath(sourceFilePath)
-    if (!fs.exists(sourcePath))
+    if (!fs.exists(sourcePath)) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "does 
not exist(不存在)."
       )
+    }
     val zipFile = FsPath.getFsPath(zipFilePath, fileName)
-    if (fs.exists(zipFile))
+    if (fs.exists(zipFile)) {
       throw new IOException(
         zipFilePath + "The name exists under the directory(目录下存在名字为):" + 
fileName + "Package file(打包文件)."
       )
+    }
     val sourceFiles = fs.list(sourcePath)
-    if (null == sourceFiles || sourceFiles.size() < 1)
+    if (null == sourceFiles || sourceFiles.size() < 1) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "There 
are no files in it, no need to compress.(里面不存在文件,无需压缩.)"
       )
+    }
     Utils.tryFinally {
       val fos = fs.write(zipFile, true)
       zos = new ZipOutputStream(new BufferedOutputStream(fos))
       val bufs = new Array[Byte](BUFFER_SIZE)
-      sourceFiles.foreach { f =>
+      sourceFiles.asScala.foreach { f =>
         // Create a ZIP entity and add it to the archive(创建ZIP实体,并添加进压缩包)
         val zipEntry = new ZipEntry(f.toFile.getName)
         zos.putNextEntry(zipEntry)
@@ -82,28 +85,30 @@ object ZipUtils {
     }(IOUtils.closeQuietly(zos))
   }
 
-  @Deprecated
+  @deprecated
   def zipDir(sourceFilePath: String, zipFilePath: String, fileName: 
String)(implicit
       fileService: FileService,
       user: String
   ): Unit = {
     var bis: BufferedInputStream = null
     var zos: ZipOutputStream = null
-    if (!fileService.exists(sourceFilePath, user))
+    if (!fileService.exists(sourceFilePath, user)) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "does 
not exist(不存在)."
       )
+    }
     val zipFile = new File(zipFilePath, fileName)
-    if (fileService.exists(zipFile.getAbsolutePath, user))
+    if (fileService.exists(zipFile.getAbsolutePath, user)) {
       throw new IOException(
         zipFilePath + "The name exists under the directory(目录下存在名字为):" + 
fileName + "Package file(打包文件)."
       )
-    else fileService.createFile(zipFile.getAbsolutePath, user, true)
+    } else fileService.createFile(zipFile.getAbsolutePath, user, true)
     val sourceFiles = fileService.listFileNames(sourceFilePath, user)
-    if (null == sourceFiles || sourceFiles.length < 1)
+    if (null == sourceFiles || sourceFiles.length < 1) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "There 
are no files in it, no need to compress(里面不存在文件,无需压缩)."
       )
+    }
     Utils.tryFinally {
       val fos = fileService.append(zipFile.getAbsolutePath, user, true)
       zos = new ZipOutputStream(new BufferedOutputStream(fos))
@@ -142,20 +147,23 @@ object ZipUtils {
     val sourceFile = new File(sourceFilePath)
     var bis: BufferedInputStream = null
     var zos: ZipOutputStream = null
-    if (!sourceFile.exists())
+    if (!sourceFile.exists()) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "does 
not exist(不存在)."
       )
+    }
     val zipFile = new File(zipFilePath + "/" + fileName)
-    if (zipFile.exists())
+    if (zipFile.exists()) {
       throw new IOException(
         zipFilePath + "The name exists under the directory(目录下存在名字为):" + 
fileName + "Package file(打包文件)."
       )
+    }
     val sourceFiles = sourceFile.listFiles()
-    if (null == sourceFiles || sourceFiles.length < 1)
+    if (null == sourceFiles || sourceFiles.length < 1) {
       throw new IOException(
         "File directory to be compressed(待压缩的文件目录):" + sourceFilePath + "There 
are no files in it, no need to compress(里面不存在文件,无需压缩)."
       )
+    }
     Utils.tryFinally {
       val fos = new FileOutputStream(zipFile)
       zos = new ZipOutputStream(new BufferedOutputStream(fos))
@@ -203,7 +211,7 @@ object ZipUtils {
     }
   }
 
-  @Deprecated
+  @deprecated
   def unzipDir(zipFilePath: String, unzipDir: String)(implicit
       fileService: FileService,
       user: String
@@ -211,8 +219,9 @@ object ZipUtils {
     val zipIn = new ZipInputStream(fileService.open(zipFilePath, user))
     Utils.tryFinally {
       val destDir = new FsPath(unzipDir)
-      if (!fileService.exists(unzipDir, user))
+      if (!fileService.exists(unzipDir, user)) {
         fileService.mkdirs(unzipDir, user, true)
+      }
       var entry = zipIn.getNextEntry
       while (entry != null) {
         val filePath = destDir.getPath + File.separator + entry.getName
@@ -227,7 +236,7 @@ object ZipUtils {
     }(IOUtils.closeQuietly(zipIn))
   }
 
-  @Deprecated
+  @deprecated
   private def extractPath(zipIn: ZipInputStream, destFilePath: String)(implicit
       fileService: FileService,
       user: String
@@ -253,10 +262,11 @@ object ZipUtils {
     val zipIn = new ZipInputStream(fs.read(new FsPath(zipFilePath)))
     Utils.tryFinally {
       val destDir = new FsPath(unzipDir)
-      if (!fs.exists(destDir))
+      if (!fs.exists(destDir)) {
         // TODO never goto here
         // fs.create("mkdirs " + unzipDir)
         fs.mkdir(new FsPath(unzipDir))
+      }
       var entry = zipIn.getNextEntry
       while (entry != null) {
         val filePath = destDir.getPath + File.separator + entry.getName
@@ -302,8 +312,9 @@ object ZipUtils {
     val zipIn = new ZipInputStream(new FileInputStream(zipFilePath))
     Utils.tryFinally {
       val destDir = new File(unzipDir)
-      if (!destDir.exists())
+      if (!destDir.exists()) {
         destDir.mkdir()
+      }
       var entry = zipIn.getNextEntry
       while (entry != null) {
         val filePath = destDir.getPath + File.separator + entry.getName


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to