attilapiros commented on code in PR #55720:
URL: https://github.com/apache/spark/pull/55720#discussion_r3228783683


##########
sql/connect/client/jvm/src/main/scala/org/apache/spark/sql/application/ConnectRepl.scala:
##########
@@ -100,11 +101,43 @@ Spark session available as 'spark'.
         |
         |spark.registerClassFinder(new AmmoniteClassFinder(repl.sess))
         |""".stripMargin
+    val main = newAmmoniteMain(
+      welcomeBannerText = splash.format(spark_version, spark.version),
+      predefCode = predefCode,
+      inputStream = inputStream,
+      outputStream = outputStream,
+      errorStream = errorStream)
+
+    if (semaphore.nonEmpty) {
+      // Used for testing.
+      main.run(sparkBind, new Bind[Semaphore]("semaphore", semaphore.get))
+    } else {
+      main.run(sparkBind)
+    }
+  }
+
+  /**
+   * Construct the [[ammonite.Main]] used by the Spark Connect REPL.
+   *
+   * The default [[ammonite.runtime.Storage.Folder]] backend persists 
Ammonite's compile cache
+   * under `~/.ammonite`. When the Connect REPL is started a second time from 
the same working
+   * directory, the cached `CodePredef` class is reloaded but its reference to 
the per-session
+   * `ArgsPredef` helper is stale, which causes a `NullPointerException` 
during predef
+   * initialization (SPARK-56448). Using [[ammonite.runtime.Storage.InMemory]] 
keeps the compile
+   * cache scoped to a single REPL session and avoids the stale-cache failure 
on restart.
+   */
+  private[application] def newAmmoniteMain(

Review Comment:
   Usually we prefer minimal changes and here this new function has no real 
value as it is only called from one place . So can you please revert this back?
   
   The function's scaladoc can be comment inside...



-- 
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