KotlinSparkInterpreter extends Interpreter { @Override public void cancel(InterpreterContext context) throws InterpreterException { if (isSparkVersionUnsupported()) { return; } jsc.cancelJobGroup(buildJobGroupId(context)); interpreter.cancel(context); } KotlinSparkInterpreter(Properties properties); @Override void open(); @Override void close(); @Override InterpreterResult interpret(String st, InterpreterContext context); @Override void cancel(InterpreterContext context); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override List<InterpreterCompletion> completion(String buf, int cursor,
      InterpreterContext interpreterContext);  }
@Test public void testCancel() throws Exception { Thread t = new Thread(() -> { try { InterpreterResult result = interpreter.interpret( "spark.range(10).foreach { Thread.sleep(1000) }", context); assertEquals(ERROR, result.code()); assertTrue(result.message().get(0).getData().trim().contains("cancelled")); } catch (UnsupportedClassVersionError e) { if (sparkSupported) { Assert.fail(e.getMessage()); } } catch (InterpreterException e) { Assert.fail(e.getMessage()); } }); t.start(); Thread.sleep(1000); interpreter.cancel(context); }