Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Loth2017-07-10 01:28:26 -0400
committerSarika Sinha2017-07-10 01:28:26 -0400
commit465c87e07610ac0a20f82045da689815deaaffb2 (patch)
tree0ecdaab20f8651d3f77f952e07caf0a20df17d26
parent37849a2dc5e14ae4a58bdc5699b77466db1b0b0a (diff)
downloadeclipse.platform.debug-465c87e07610ac0a20f82045da689815deaaffb2.tar.gz
eclipse.platform.debug-465c87e07610ac0a20f82045da689815deaaffb2.tar.xz
eclipse.platform.debug-465c87e07610ac0a20f82045da689815deaaffb2.zip
Bug 518909 - Regression: IOConsoleOutputStream.setEncoding(String)
cannot handle null argument anymore Change-Id: I5bb76e1c850a80b88f6f5e82a9e7fceacd6d6d8c Signed-off-by: Andreas Loth <andy_2639@justmail.de>
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java7
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java9
2 files changed, 15 insertions, 1 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
index d0704a8d9..d1f315a62 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
@@ -137,4 +137,11 @@ public class ConsoleTests extends AbstractDebugTest {
}
}
+ public void testSetNullEncoding() throws IOException {
+ MessageConsole console = new MessageConsole("Test Console 6", null); //$NON-NLS-1$
+ try (IOConsoleOutputStream outStream = console.newOutputStream()) {
+ outStream.setEncoding(null);
+ }
+ }
+
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java
index 0cba219c1..6f9c55950 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java
@@ -16,6 +16,7 @@ import java.io.OutputStream;
import java.nio.charset.Charset;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.WorkbenchEncoding;
import org.eclipse.ui.internal.console.IOConsolePartitioner;
import org.eclipse.ui.internal.console.StreamDecoder;
@@ -311,7 +312,13 @@ public class IOConsoleOutputStream extends OutputStream {
* @param encoding encoding identifier
*/
public void setEncoding(String encoding) {
- Charset charset = Charset.forName(encoding);
+ String charsetName;
+ if (encoding == null) {
+ charsetName = WorkbenchEncoding.getWorkbenchDefaultEncoding();
+ } else {
+ charsetName = encoding;
+ }
+ Charset charset = Charset.forName(charsetName);
try {
this.setCharset(charset);
} catch (IOException ioe) {

Back to the top