spark-client/src/test/java/org/apache/hive/spark/client/TestSparkClient.java
private void waitForSparkContextShutdown() throws InterruptedException {
    for (int i = 0; i < 100; i++) {
      if (SparkContext$.MODULE$.getActive().isEmpty()) {
        break;
      }
      Thread.sleep(100);
    }
    if (!SparkContext$.MODULE$.getActive().isEmpty()) {
      throw new IllegalStateException("SparkContext did not shutdown in time");
    }
  }
/**
   * This was added to avoid a race condition where we try to create multiple SparkContexts in
   * the same process. Since spark.master = local everything is run in the same JVM. Since we
   * don't wait for the RemoteDriver to shutdown it's SparkContext, its possible that we finish a
   * test before the SparkContext has been shutdown. In order to avoid the multiple SparkContexts
   * in a single JVM exception, we wait for the SparkContext to shutdown after each test.
   */
This was added to avoid a race condition where we try to create multiple SparkContexts in
the same process. Since spark.master = local everything is run in the same JVM. Since we
don't wait for the RemoteDriver to shutdown it's SparkContext, its possible that we finish a
test before the SparkContext has been shutdown. In order to avoid the multiple SparkContexts
in a single JVM exception, we wait for the SparkContext to shutdown after each test.
This was added to avoid a race condition where we try to create multiple SparkContexts in the same process . Since spark . master = local everything is run in the same JVM . Since we don ' t wait for the RemoteDriver to shutdown it ' s SparkContext its possible that we finish a test before the SparkContext has been shutdown . In order to avoid the multiple SparkContexts in a single JVM exception we wait for the SparkContext to shutdown after each test .
private void waitForSparkContextShutdown() throws InterruptedException {
    for (int i = 0; i < 100; i++) {
      if (SparkContext$.MODULE$.getActive().isEmpty()) {
        break;
      }
      Thread.sleep(100);
    }
    if (!SparkContext$.MODULE$.getActive().isEmpty()) {
      throw new IllegalStateException("SparkContext did not shutdown in time");
    }
  }
private void waitForSparkContextShutdown ( ) throws InterruptedException { for ( int i = 0 ; i < 100 ; i ++ ) { if ( SparkContext$ . MODULE$ . getActive ( ) . isEmpty ( ) ) { break ; } Thread . sleep ( 100 ) ; } if ( ! SparkContext$ . MODULE$ . getActive ( ) . isEmpty ( ) ) { throw new IllegalStateException ( "SparkContext did not shutdown in time" ) ; } }
This was added to avoid a race condition where we try to create multiple SparkContexts in
 the same process.
This was added to avoid a race condition where we try to create multiple SparkContexts in the same process .