Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Loth2017-07-10 01:28:26 -0400
committerSarika Sinha2017-07-10 02:11:32 -0400
commit660b0650be07e7a5a955cec1dcc5a6f7081c20ef (patch)
tree85a440ebd86b672bf323ae781081249f036d32c7
parente59696e365653f7df42821c8bec89bbae40e6f2e (diff)
downloadeclipse.platform.debug-660b0650be07e7a5a955cec1dcc5a6f7081c20ef.tar.gz
eclipse.platform.debug-660b0650be07e7a5a955cec1dcc5a6f7081c20ef.tar.xz
eclipse.platform.debug-660b0650be07e7a5a955cec1dcc5a6f7081c20ef.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 fb05f3ef5..e63525306 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
@@ -135,4 +135,11 @@ public class ConsoleTests extends TestCase {
}
}
+ 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