diff --git a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java index 843bb9c1b48f..f30025eeb12b 100644 --- a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java +++ b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java @@ -26,7 +26,6 @@ import java.io.PrintWriter; import java.io.StringWriter; public final class IdeaAntLogger2 extends DefaultLogger { - static SegmentedOutputStream ourOut; static SegmentedOutputStream ourErr; public static final char MESSAGE_CONTENT = 'M'; public static final char EXCEPTION_CONTENT = 'X'; @@ -116,19 +115,16 @@ public final class IdeaAntLogger2 extends DefaultLogger { } public static void guardStreams() { - if (ourErr != null && ourOut != null) return; - PrintStream out = System.out; + if (ourErr != null) { + return; + } PrintStream err = System.err; - ourOut = new SegmentedOutputStream(out); ourErr = new SegmentedOutputStream(err); - System.setOut(new PrintStream(ourOut)); System.setErr(new PrintStream(ourErr)); - ourOut.sendStart(); ourErr.sendStart(); } private void send(PacketWriter packet) { - packet.sendThrough(ourOut); packet.sendThrough(ourErr); } diff --git a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaInputHandler.java b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaInputHandler.java index 67c3f148ffd8..3a1120acd320 100644 --- a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaInputHandler.java +++ b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaInputHandler.java @@ -30,32 +30,42 @@ import java.util.Vector; */ public class IdeaInputHandler implements InputHandler { public void handleInput(InputRequest request) throws BuildException { - String prompt = request.getPrompt(); - if (prompt == null) throw new BuildException("Prompt is null"); - SegmentedOutputStream out = IdeaAntLogger2.ourOut; - SegmentedOutputStream err = IdeaAntLogger2.ourErr; - if (out == null || err == null) + final String prompt = request.getPrompt(); + if (prompt == null) { + throw new BuildException("Prompt is null"); + } + final SegmentedOutputStream err = IdeaAntLogger2.ourErr; + if (err == null) { throw new BuildException("Selected InputHandler should be used by Intellij IDEA"); - PacketWriter packet = PacketFactory.ourInstance.createPacket(IdeaAntLogger2.INPUT_REQUEST); + } + final PacketWriter packet = PacketFactory.ourInstance.createPacket(IdeaAntLogger2.INPUT_REQUEST); packet.appendLimitedString(prompt); if (request instanceof MultipleChoiceInputRequest) { Vector choices = ((MultipleChoiceInputRequest)request).getChoices(); if (choices != null && choices.size() > 0) { int count = choices.size(); packet.appendLong(count); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { packet.appendLimitedString((String)choices.elementAt(i)); - } else packet.appendLong(0); - } else packet.appendLong(0); - packet.sendThrough(out); + } + } + else { + packet.appendLong(0); + } + } + else { + packet.appendLong(0); + } packet.sendThrough(err); try { - byte[] replayLength = readBytes(4); - int length = ((int)replayLength[0] << 24) | ((int)replayLength[1] << 16) | ((int)replayLength[2] << 8) | replayLength[3]; - byte[] replay = readBytes(length); - String input = new String(replay); + final byte[] replayLength = readBytes(4); + final int length = ((int)replayLength[0] << 24) | ((int)replayLength[1] << 16) | ((int)replayLength[2] << 8) | replayLength[3]; + final byte[] replay = readBytes(length); + final String input = new String(replay); request.setInput(input); - if (!request.isInputValid()) throw new BuildException("Invalid input: " + input); + if (!request.isInputValid()) { + throw new BuildException("Invalid input: " + input); + } } catch (IOException e) { throw new BuildException(e); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java index 6b2b629dde2b..700d97b362c0 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java @@ -16,7 +16,10 @@ package com.intellij.lang.ant.config.execution; import com.intellij.execution.junit.JUnitProcessHandler; -import com.intellij.execution.junit2.segments.*; +import com.intellij.execution.junit2.segments.DeferredActionsQueue; +import com.intellij.execution.junit2.segments.DeferredActionsQueueImpl; +import com.intellij.execution.junit2.segments.InputConsumer; +import com.intellij.execution.junit2.segments.SegmentReader; import com.intellij.execution.process.OSProcessHandler; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.lang.ant.config.AntBuildFile; @@ -85,9 +88,8 @@ final class OutputParser2 extends OutputParser implements PacketProcessor, Input final AntBuildMessageView errorView, final ProgressIndicator progress, final AntBuildFile buildFile) { - OutputParser2 parser = new OutputParser2(myProject, handler, errorView, progress, buildFile.getName()); - DeferredActionsQueue queue = new DeferredActionsQueueImpl(); - handler.getOut().setPacketDispatcher(parser, queue); + final OutputParser2 parser = new OutputParser2(myProject, handler, errorView, progress, buildFile.getName()); + final DeferredActionsQueue queue = new DeferredActionsQueueImpl(); handler.getErr().setPacketDispatcher(parser, queue); return parser; }