attilapiros commented on code in PR #55720: URL: https://github.com/apache/spark/pull/55720#discussion_r3213200472
########## sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/application/ConnectReplSuite.scala: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.application + +import java.io.{ByteArrayInputStream, ByteArrayOutputStream} + +import ammonite.util.Bind + +import org.apache.spark.sql.connect.test.ConnectFunSuite + +class ConnectReplSuite extends ConnectFunSuite { + + test("SPARK-56448: restarting the Connect REPL does not throw NPE") { + // Reproduces the scenario from SPARK-56448: prior to the fix, starting the Connect + // REPL a second time from the same working directory caused Ammonite to reload a + // cached `CodePredef` whose reference to the per-session `ArgsPredef` helper was + // stale, producing a `NullPointerException` during predef initialization. The fix + // wires `Storage.InMemory` in `ConnectRepl.newAmmoniteMain` so nothing is persisted + // across sessions. This test exercises `newAmmoniteMain` twice with the same predef + // and bind setup and asserts that neither start throws. + def startRepl(): Unit = { + val in = new ByteArrayInputStream(Array.emptyByteArray) + val out = new ByteArrayOutputStream() + val err = new ByteArrayOutputStream() + val main = ConnectRepl.newAmmoniteMain( + welcomeBannerText = "", + predefCode = "val x = 1", + inputStream = in, + outputStream = out, + errorStream = err) + // A `Bind` is required to exercise the `ArgsPredef` → `CodePredef` wiring that is Review Comment: Avoid non-ascii char here: ```suggestion // A `Bind` is required to exercise the `ArgsPredef` -> `CodePredef` wiring that is ``` Otherwise Scalastyle fails with: ``` Scalastyle checks failed at following occurrences: [error] /__w/spark/spark/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/application/ConnectReplSuite.scala:44:26: nonascii.message ``` -- 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]
