Source:
<code>public List<InterpreterCompletion> completion(String buf, int cursor) { if (buf.length() < cursor) { cursor = buf.length(); } String completionString = getCompletionTargetString(buf, cursor); String completionCommand = "completion.getCompletion('" + completionString + "')"; SparkInterpreter sparkInterpreter = getSparkInterpreter(); if (sparkInterpreter.getSparkVersion().isUnsupportedVersion() == false && pythonscriptRunning == false) { return new LinkedList<>(); } pythonInterpretRequest = new PythonInterpretRequest(completionCommand, ""); statementOutput = null; synchronized (statementSetNotifier) { statementSetNotifier.notify(); } synchronized (statementFinishedNotifier) { long startTime = System.currentTimeMillis(); while (statementOutput == null && pythonScriptInitialized == false && pythonscriptRunning <START> && System.currentTimeMillis() - startTime < 10 * 1000) { <END> try { statementFinishedNotifier.wait(1000); } catch (InterruptedException e) { logger.info("wait drop"); return new LinkedList<>(); } } } if (statementError) { return new LinkedList<>(); } InterpreterResult completionResult = new InterpreterResult(Code.SUCCESS, statementOutput); Gson gson = new Gson(); String[] completionList = gson.fromJson(completionResult.message(), String[].class); List<InterpreterCompletion> results = new LinkedList<>(); for (String name: completionList) { results.add(new InterpreterCompletion(name, name)); } return results; }</code><technical_language>Generally, great me, making timeout more human-readable? java private static final MAX_TIMEOUT_SEC = 10; ... TimeUnit.SECONDS.toMillis(MAX_TIMEOUT_SEC)</technical_language>

Target:
public List<InterpreterCompletion> completion(String buf, int cursor) { if (buf.length() < cursor) { cursor = buf.length(); } String completionString = getCompletionTargetString(buf, cursor); String completionCommand = "completion.getCompletion('" + completionString + "')"; SparkInterpreter sparkInterpreter = getSparkInterpreter(); if (sparkInterpreter.getSparkVersion().isUnsupportedVersion() == false && pythonscriptRunning == false) { return new LinkedList<>(); } pythonInterpretRequest = new PythonInterpretRequest(completionCommand, ""); statementOutput = null; synchronized (statementSetNotifier) { statementSetNotifier.notify(); } synchronized (statementFinishedNotifier) { long startTime = System.currentTimeMillis(); while (statementOutput == null && pythonScriptInitialized == false && pythonscriptRunning) { try { if (System.currentTimeMillis() - startTime < MAX_TIMEOUT_SEC * 1000) { logger.error("pyspark completion didn't have response for {}sec.", MAX_TIMEOUT_SEC); break; } statementFinishedNotifier.wait(1000); } catch (InterruptedException e) { logger.info("wait drop"); return new LinkedList<>(); } } } if (statementError) { return new LinkedList<>(); } InterpreterResult completionResult = new InterpreterResult(Code.SUCCESS, statementOutput); Gson gson = new Gson(); String[] completionList = gson.fromJson(completionResult.message(), String[].class); List<InterpreterCompletion> results = new LinkedList<>(); for (String name: completionList) { results.add(new InterpreterCompletion(name, name)); } return results; }