This repository has been archived on 2026-01-16. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
accumulo/jline-shell-workaround.patch
2017-03-17 11:23:37 -04:00

53 lines
2.4 KiB
Diff

diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 9231c78..0336a67 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -228,6 +228,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
private long lastUserActivity = System.nanoTime();
private boolean logErrorsToConsole = false;
private boolean masking = false;
+ private PrintWriter writer = null;
{
// set the JLine output encoding to some reasonable default if it isn't already set
@@ -250,6 +251,8 @@ public class Shell extends ShellOptions implements KeywordExecutable {
public Shell(ConsoleReader reader) {
super();
this.reader = reader;
+ this.writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding",
+System.getProperty("file.encoding")))));
}
/**
@@ -262,6 +265,8 @@ public class Shell extends ShellOptions implements KeywordExecutable {
public boolean config(String... args) throws IOException {
if (this.reader == null)
this.reader = new ConsoleReader();
+ if (this.writer == null)
+ this.writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding", System.getProperty("file.encoding")))));
ShellOptionsJC options = new ShellOptionsJC();
JCommander jc = new JCommander();
@@ -646,9 +646,10 @@ public class Shell extends ShellOptions {
}
public void printInfo() throws IOException {
- reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: "
+ writer.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: "
+ connector.getInstance().getInstanceName() + "\n" + "- instance id: " + connector.getInstance().getInstanceID() + "\n" + "- \n"
+ "- type 'help' for a list of available commands\n" + "- \n");
+ writer.flush();
reader.flush();
}
@@ -676,7 +677,9 @@ public class Shell extends ShellOptions {
}
}
sb.append("-\n");
- reader.print(sb.toString());
+ writer.print(sb.toString());
+ writer.flush();
+ reader.flush();
}
public String getDefaultPrompt() {