Skip to content

Commit

Permalink
Jline silently ignore streams(in, out) when using a system Terminal, f…
Browse files Browse the repository at this point in the history
…ixes #576
  • Loading branch information
mattirn committed Oct 8, 2020
1 parent 7fdedc3 commit ad90e03
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ public TerminalBuilder codepage(int codepage) {
/**
* Attributes to use when creating a non system terminal,
* i.e. when the builder has been given the input and
* outut streams using the {@link #streams(InputStream, OutputStream)} method
* or when {@link #system(boolean)} has been explicitely called with
* output streams using the {@link #streams(InputStream, OutputStream)} method
* or when {@link #system(boolean)} has been explicitly called with
* <code>false</code>.
*
* @param attributes the attributes to use
Expand All @@ -222,7 +222,7 @@ public TerminalBuilder attributes(Attributes attributes) {
* Initial size to use when creating a non system terminal,
* i.e. when the builder has been given the input and
* output streams using the {@link #streams(InputStream, OutputStream)} method
* or when {@link #system(boolean)} has been explicitely called with
* or when {@link #system(boolean)} has been explicitly called with
* <code>false</code>.
*
* @param size the initial size
Expand Down Expand Up @@ -316,6 +316,9 @@ private Terminal doBuild() throws IOException {
dumb = getBoolean(PROP_DUMB, null);
}
if ((system != null && system) || (system == null && in == null && out == null)) {
if (system != null && ((in != null && !in.equals(System.in)) || (out != null && !out.equals(System.out)))) {
throw new IllegalArgumentException("Cannot create a system terminal using non System streams");
}
if (attributes != null || size != null) {
Log.warn("Attributes and size fields are ignored when creating a system terminal");
}
Expand Down Expand Up @@ -521,7 +524,7 @@ private <S> S load(Class<S> clazz) {
* @param terminal the {@link Terminal} to globally override
*/
@Deprecated
public static final void setTerminalOverride(final Terminal terminal) {
public static void setTerminalOverride(final Terminal terminal) {
TERMINAL_OVERRIDE.set(terminal);
}
}

0 comments on commit ad90e03

Please sign in to comment.