zhztheplayer commented on code in PR #10708:
URL: 
https://github.com/apache/incubator-gluten/pull/10708#discussion_r2422098071


##########
gluten-core/src/main/scala/org/apache/spark/util/SparkDirectoryUtil.scala:
##########
@@ -67,30 +67,31 @@ class SparkDirectoryUtil private (val roots: Array[String]) 
extends Logging {
 }
 
 object SparkDirectoryUtil extends Logging {
-  private var INSTANCE: SparkDirectoryUtil = _
+  @volatile private var targetRoots: Array[String] = _
+  private lazy val INSTANCE: SparkDirectoryUtil = {
+    if (targetRoots == null) {
+      throw new IllegalStateException("SparkDirectoryUtil not initialized")
+    }
+    new SparkDirectoryUtil(targetRoots)
+  }
 
-  def init(conf: SparkConf): Unit = synchronized {
+  def init(conf: SparkConf): Unit = {
     val roots = Utils.getConfiguredLocalDirs(conf)
     init(roots)
   }
 
   private def init(roots: Array[String]): Unit = synchronized {
-    if (INSTANCE == null) {
-      INSTANCE = new SparkDirectoryUtil(roots)
-      return
-    }
-    if (INSTANCE.roots.toSet != roots.toSet) {
+    if (targetRoots == null) {
+      targetRoots = roots

Review Comment:
   Perhaps just use the same name and
   
   ```scala
   this.roots = roots
   ```
   
   . Just a nit. Both are fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to