From e5d5a40e85cdf4c3788f7ecd2139b9d7ca784702 Mon Sep 17 00:00:00 2001 From: Paul Pazderski Date: Thu, 19 Dec 2019 22:57:13 +0100 Subject: Bug 558489 - [console] Remove unnecessary recoding in ProcessConsole output handling Apart from removing an unnecessary string -> bytes -> string round trip it fix a potential content corruption since the source (TextConsole) encoding and target (IOConsoleOutputStream) encoding can differ. Also the stream listener implementation in ProcessConsole is simplified a lot and lost some dead code. Last but not least it replaced some usages of encoding names as strings with using the Charset class to reduce overall number of charset lookups. Change-Id: Ie94aa433e571a2f9898c950d2997f598618aca18 Signed-off-by: Paul Pazderski --- .../org/eclipse/debug/internal/core/StreamsProxy.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java') diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java index 616e79674..19df55e28 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java @@ -15,6 +15,7 @@ package org.eclipse.debug.internal.core; import java.io.IOException; +import java.nio.charset.Charset; import org.eclipse.debug.core.model.IStreamMonitor; import org.eclipse.debug.core.model.IStreamsProxy; @@ -43,20 +44,21 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 { * false by default. */ private boolean fClosed; + /** - * Creates a StreamsProxy on the streams - * of the given system process. + * Creates a StreamsProxy on the streams of the given system + * process. * * @param process system process to create a streams proxy on - * @param encoding the process's encoding or null if default + * @param charset the process's charset or null if default */ - public StreamsProxy(Process process, String encoding) { + public StreamsProxy(Process process, Charset charset) { if (process == null) { return; } - fOutputMonitor= new OutputStreamMonitor(process.getInputStream(), encoding); - fErrorMonitor= new OutputStreamMonitor(process.getErrorStream(), encoding); - fInputMonitor= new InputStreamMonitor(process.getOutputStream(), encoding); + fOutputMonitor = new OutputStreamMonitor(process.getInputStream(), charset); + fErrorMonitor = new OutputStreamMonitor(process.getErrorStream(), charset); + fInputMonitor = new InputStreamMonitor(process.getOutputStream(), charset); fOutputMonitor.startMonitoring(); fErrorMonitor.startMonitoring(); fInputMonitor.startMonitoring(); -- cgit v1.2.3