diff --git a/file/src/main/java/org/apache/zeppelin/file/FileInterpreter.java b/file/src/main/java/org/apache/zeppelin/file/FileInterpreter.java index 286d315ba83..50592cc5f35 100644 --- a/file/src/main/java/org/apache/zeppelin/file/FileInterpreter.java +++ b/file/src/main/java/org/apache/zeppelin/file/FileInterpreter.java @@ -24,6 +24,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Properties; @@ -167,6 +168,6 @@ public Scheduler getScheduler() { @Override public List completion(String buf, int cursor, InterpreterContext interpreterContext) { - return null; + return Collections.emptyList(); } } diff --git a/file/src/test/java/org/apache/zeppelin/file/FileInterpreterTest.java b/file/src/test/java/org/apache/zeppelin/file/FileInterpreterTest.java index 6097d5fc59b..01066a1fed6 100644 --- a/file/src/test/java/org/apache/zeppelin/file/FileInterpreterTest.java +++ b/file/src/test/java/org/apache/zeppelin/file/FileInterpreterTest.java @@ -19,12 +19,15 @@ package org.apache.zeppelin.file; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; +import java.util.List; import java.util.Properties; import org.apache.zeppelin.interpreter.InterpreterException; +import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; import org.junit.jupiter.api.Test; /** @@ -178,4 +181,14 @@ void testComplexCommand() { assertTrue(args.flags.contains('h')); assertFalse(args.flags.contains('-')); } + + @Test + void testCompletionReturnsEmptyListInsteadOfNull() { + TestFileInterpreter interpreter = new TestFileInterpreter(new Properties()); + + List completions = interpreter.completion("ls", 2, null); + + assertNotNull(completions, "completion() should never return null"); + assertTrue(completions.isEmpty(), "Default completion() should return an empty list"); + } }