From d7181b93c3d10cb6408a52ffcd4268beaef0c2ef Mon Sep 17 00:00:00 2001 From: Annie Liang <64233642+xinlian12@users.noreply.github.com> Date: Tue, 19 Oct 2021 23:23:54 -0700 Subject: [PATCH] remove securityManager (#24562) Co-authored-by: annie-mac --- .../scala/com/azure/cosmos/spark/SparkUtils.scala | 14 ++------------ .../rntbd/RntbdThreadFactory.java | 10 +--------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-spark_3-1_2-12/src/main/scala/com/azure/cosmos/spark/SparkUtils.scala b/sdk/cosmos/azure-cosmos-spark_3-1_2-12/src/main/scala/com/azure/cosmos/spark/SparkUtils.scala index 6823f5a4fc74a..9709afd68c57f 100644 --- a/sdk/cosmos/azure-cosmos-spark_3-1_2-12/src/main/scala/com/azure/cosmos/spark/SparkUtils.scala +++ b/sdk/cosmos/azure-cosmos-spark_3-1_2-12/src/main/scala/com/azure/cosmos/spark/SparkUtils.scala @@ -7,10 +7,9 @@ import com.azure.cosmos.CosmosAsyncContainer import com.azure.cosmos.spark.diagnostics.ILogger import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.ObjectNode -import org.slf4j.LoggerFactory -import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.ThreadFactory +import java.util.concurrent.atomic.AtomicInteger private object SparkUtils { @@ -47,20 +46,11 @@ private object SparkUtils { } private class DaemonThreadFactory extends ThreadFactory { - private val securityManager = System.getSecurityManager - private val threadGroup = Option.apply(securityManager) match { - case Some(s) => s.getThreadGroup - case None => Thread.currentThread.getThreadGroup - } private val threadNumber = new AtomicInteger(1) private val namePrefix = "cosmos-spark-daemon-pool-" + DaemonThreadFactory.poolNumber.getAndIncrement + "-thread-" override def newThread(r: Runnable): Thread = { - val t = new Thread( - threadGroup, - r, - namePrefix + threadNumber.getAndIncrement, - 0) + val t = new Thread(r, namePrefix + threadNumber.getAndIncrement) if (!t.isDaemon) t.setDaemon(true) if (t.getPriority != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY) t diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdThreadFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdThreadFactory.java index 36fd22219d953..124e57c3f27ba 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdThreadFactory.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdThreadFactory.java @@ -18,18 +18,10 @@ class RntbdThreadFactory implements ThreadFactory { private final boolean daemon; private final String name; private final int priority; - private final ThreadGroup threadGroup; private final AtomicInteger threadCount; @SuppressWarnings("removal") RntbdThreadFactory(final String name, final boolean daemon, final int priority) { - - final SecurityManager securityManager = System.getSecurityManager(); - - this.threadGroup = securityManager != null - ? securityManager.getThreadGroup() - : Thread.currentThread().getThreadGroup(); - this.daemon = daemon; this.name = name; this.priority = priority; @@ -40,7 +32,7 @@ class RntbdThreadFactory implements ThreadFactory { public Thread newThread(final Runnable runnable) { final String name = lenientFormat(NAME_TEMPLATE, this.name, this.threadCount.incrementAndGet()); - final Thread thread = new Thread(this.threadGroup, runnable, name, 0); + final Thread thread = new Thread(runnable, name); if (thread.isDaemon() != this.daemon) { thread.setDaemon(this.daemon);