From df630e1e04c0c13be0d0349e91df417208404663 Mon Sep 17 00:00:00 2001 From: aiceflower Date: Mon, 13 Jan 2025 13:20:34 +0800 Subject: [PATCH] code format & fix sonar check --- .../org/apache/linkis/storage/fs/impl/HDFSFileSystem.java | 5 +++-- .../org/apache/linkis/storage/domain/MethodEntity.scala | 1 + .../org/apache/linkis/manager/am/conf/AMConfiguration.java | 3 ++- .../common/entity/resource/LoadInstanceResource.java | 4 ++-- .../spark/client/deployment/util/FileUtils.java | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/fs/impl/HDFSFileSystem.java b/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/fs/impl/HDFSFileSystem.java index 8f4537bb0d..b452376b91 100644 --- a/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/fs/impl/HDFSFileSystem.java +++ b/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/fs/impl/HDFSFileSystem.java @@ -60,7 +60,8 @@ public class HDFSFileSystem extends FileSystem { private static final String LOCKER_SUFFIX = "refresh"; - private static final int REFRESH_INTERVAL = LinkisStorageConf.HDFS_FILE_SYSTEM_REFRESHE_INTERVAL() * 1000 * 60; + private static final int REFRESH_INTERVAL = + LinkisStorageConf.HDFS_FILE_SYSTEM_REFRESHE_INTERVAL() * 1000 * 60; private static final ConcurrentHashMap lastCallTimes = new ConcurrentHashMap<>(); @@ -336,7 +337,7 @@ public boolean exists(FsPath dest) throws IOException { private void resetRootHdfs() { if (fs != null) { String locker = user + LOCKER_SUFFIX; - synchronized (locker.intern()) { + synchronized (locker.intern()) { // NOSONAR if (fs != null) { if (HadoopConf.HDFS_ENABLE_CACHE()) { long currentTime = System.currentTimeMillis(); diff --git a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/MethodEntity.scala b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/MethodEntity.scala index a9aa406e1b..6da18d43fc 100644 --- a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/MethodEntity.scala +++ b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/MethodEntity.scala @@ -18,6 +18,7 @@ package org.apache.linkis.storage.domain import java.lang.reflect.Type + import com.google.gson.{GsonBuilder, ToNumberPolicy} /** diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java index 2c5b0ba1c9..f233547338 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java @@ -101,7 +101,8 @@ public class AMConfiguration { CommonVars.apply("wds.linkis.allow.batch.kill.engine.types", "spark,hive,python"); public static final CommonVars UNALLOW_BATCH_KILL_ENGINE_TYPES = - CommonVars.apply("wds.linkis.unallow.batch.kill.engine.types", "trino,appconn,io_file,jdbc,nebula"); + CommonVars.apply( + "wds.linkis.unallow.batch.kill.engine.types", "trino,appconn,io_file,jdbc,nebula"); public static final CommonVars MULTI_USER_ENGINE_USER = CommonVars.apply("wds.linkis.multi.user.engine.user", getDefaultMultiEngineUser()); public static final String UDF_KILL_ENGINE_TYPE = diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/LoadInstanceResource.java b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/LoadInstanceResource.java index 0067c5e797..3cb16ef346 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/LoadInstanceResource.java +++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/LoadInstanceResource.java @@ -192,10 +192,10 @@ public int getCores() { } public int getInstances() { - return instances; + return this.instances; } public int getInstance() { - return instances; + return this.instances; // NOSONAR } } diff --git a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java index 57c375c804..c85632e198 100644 --- a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java +++ b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java @@ -27,8 +27,8 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; +import java.security.SecureRandom; import java.util.Arrays; -import java.util.Random; import java.util.stream.Stream; /** @@ -63,7 +63,7 @@ public final class FileUtils { public static final String PACKAGE_SEPARATOR = "."; - public static final Random rnd = new Random(); + public static final SecureRandom rand = new SecureRandom(); // ------------------------------------------------------------------------ @@ -96,7 +96,7 @@ public static String getRandomFilename(final String prefix) { final StringBuilder stringBuilder = new StringBuilder(prefix); for (int i = 0; i < RANDOM_FILE_NAME_LENGTH; i++) { - stringBuilder.append(ALPHABET[rnd.nextInt(ALPHABET.length)]); + stringBuilder.append(ALPHABET[rand.nextInt(ALPHABET.length)]); } return stringBuilder.toString();