diff --git a/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java b/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java index f3b595ef..f26db634 100644 --- a/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java +++ b/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java @@ -89,7 +89,7 @@ public Throwable getException() { } public void waitUntilDone() { - interrupt(); + this.interrupt(); synchronized (lock) { while (!done) { try { diff --git a/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java b/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java index fb17acb9..79fea0ed 100644 --- a/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java +++ b/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java @@ -46,9 +46,6 @@ public class StreamFeederTest { static class BlockingInputStream extends ByteArrayInputStream { - boolean endStream = false; - final Object lock = new Object(); - public BlockingInputStream(byte[] buf) { super(buf); } @@ -61,8 +58,6 @@ public synchronized int read() { } // end test data ... block - endStream = true; - try { wait(); } catch (InterruptedException e) { @@ -70,29 +65,27 @@ public synchronized int read() { } return -1; } - - public synchronized void waitForEndStream() throws InterruptedException { - while (!endStream) { - wait(100); - } - } } @Test public void waitUntilFeederDone() throws InterruptedException { - BlockingInputStream inputStream = new BlockingInputStream("TestData".getBytes()); + String TEST_DATA = "TestData"; + + BlockingInputStream inputStream = new BlockingInputStream(TEST_DATA.getBytes()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); StreamFeeder streamFeeder = new StreamFeeder(inputStream, outputStream); streamFeeder.start(); - // wait until input stream will be in block mode - inputStream.waitForEndStream(); + // wait until all data from steam will be read + while (outputStream.size()