Skip to content

Commit c6795dd

Browse files
In EditorConsole::write(), use all arguments
When System.(out|err).print was used before there was a visible EditorConsole, the message was written to the stderr/stdout by this instead of the EditorConsole. However, the write(data, offset, length) version would not pass on its offset and length parameters to the stdout/stderr stream, causing (parts of) a message to be printed multiple times. This commit makes sure the parameters are all properly passed to the real stream. For some reason the write(int) and write(byte[], int, int) methods in PrintStream do not throw an IOException like the write(byte[]) version, so the try block has to go.
1 parent 4592acc commit c6795dd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/src/processing/app/EditorConsole.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,11 @@ public void write(byte b[], int offset, int length) {
333333
if (currentConsole != null) {
334334
currentConsole.write(b, offset, length, err);
335335
} else {
336-
try {
337-
if (err) {
338-
systemErr.write(b);
339-
} else {
340-
systemOut.write(b);
341-
}
342-
} catch (IOException e) { } // just ignore, where would we write?
336+
if (err) {
337+
systemErr.write(b, offset, length);
338+
} else {
339+
systemOut.write(b, offset, length);
340+
}
343341
}
344342

345343
OutputStream echo = err ? stderrFile : stdoutFile;

0 commit comments

Comments
 (0)