This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new 420401b Fix breakages due to JLine3 upgrade
420401b is described below
commit 420401bb9fb11e8ac574a6a82fb257dbb924ed61
Author: Steve Lawrence <[email protected]>
AuthorDate: Mon Apr 12 10:19:11 2021 -0400
Fix breakages due to JLine3 upgrade
Commit 66dda260ce upgraded from JLine2 to JLine3, which resulted in some
subtle breakages:
- In JLine2, the readLine() function returned null when a user pressed
Ctrl-C or Ctrl-D. JLine3 changed this behavior so that the function
never returns null, but instead throws exceptions. This changes the
CLIDebuggerRunner to not check for null and instead catch the
appropriate exceptions.
- When the command completion code was rewritten, it compared against
the "name" field of DebuggerCommand's to figure out which command a
user had typed. This meant that if a user used short commands, e.g.
"i <TAB>", then we would not list any potential completions. This
fixes this by using == for the comparision, which compares against
both the long and short command names.
DAFFODIL-2494
---
.../apache/daffodil/debugger/CLIDebuggerRunner.scala | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git
a/daffodil-cli/src/main/scala/org/apache/daffodil/debugger/CLIDebuggerRunner.scala
b/daffodil-cli/src/main/scala/org/apache/daffodil/debugger/CLIDebuggerRunner.scala
index 7c8528c..c0c6329 100644
---
a/daffodil-cli/src/main/scala/org/apache/daffodil/debugger/CLIDebuggerRunner.scala
+++
b/daffodil-cli/src/main/scala/org/apache/daffodil/debugger/CLIDebuggerRunner.scala
@@ -24,9 +24,11 @@ import scala.io.Source
import org.jline.reader.Candidate
import org.jline.reader.Completer
+import org.jline.reader.EndOfFileException
import org.jline.reader.LineReader
import org.jline.reader.LineReaderBuilder
import org.jline.reader.ParsedLine
+import org.jline.reader.UserInterruptException
class CLIDebuggerRunner(cmdsIter: Iterator[String]) extends
InteractiveDebuggerRunner {
@@ -66,8 +68,13 @@ class CLIDebuggerRunner(cmdsIter: Iterator[String]) extends
InteractiveDebuggerR
println("%s%s".format(prompt, line))
line
} else {
- val line = reader.get.readLine(prompt)
- if (line == null) "quit" else line
+ val line = try {
+ reader.get.readLine(prompt)
+ } catch {
+ case _: UserInterruptException => "quit" // Ctrl-C
+ case _: EndOfFileException => "quit" // Ctrl-D
+ }
+ line
}
cmd.trim
}
@@ -104,8 +111,10 @@ class CLIDebuggerCompleter(id: InteractiveDebugger)
extends Completer {
// We have the name for the next command, try to find the
// associated subcommand of the current DebugCommand. If we don't
// find one, it just means they user typed something that's not a
- // valid command and we no command to use for completing
- val nextCmd = cmd.subcommands.find { _.name == nextCmdName }
+ // valid command and we have no command to use for completing. Note
+ // that by comparing using == with the RHS being a String, we match
+ // against both short and long debug command names
+ val nextCmd = cmd.subcommands.find { _ == nextCmdName }
nextCmd
}
case None => {