Skip to content

Commit

Permalink
Fix random failing OutputStreamMonitorTests eclipse-platform#898
Browse files Browse the repository at this point in the history
The testNullCharset() method of the OutputStreamMonitorTests randomly
fails. The cause is probably a too restrictive timeout of 1 seconds for
the significantly varying execution times of the test.
This change increases the timeout to 10 seconds.

Fixes eclipse-platform#898
  • Loading branch information
HeikoKlare committed Nov 30, 2023
1 parent f1c9085 commit 28d9767
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -43,6 +44,8 @@
* Tests the {@link OutputStreamMonitor}.
*/
public class OutputStreamMonitorTests extends AbstractDebugTest {
private static final Duration TIMEOUT = Duration.ofSeconds(10);

/** The {@link OutputStreamMonitor} used for the test runs. */
TestOutputStreamMonitor monitor;
/** Stream to simulate an application writing to system out. */
Expand All @@ -67,7 +70,7 @@ public void streamAppended(byte[] data, IBinaryStreamMonitor mon) {
}

public void waitForBytes(int numberOfBytes) throws Exception {
TestUtil.waitWhile(() -> recordedBytes.size() < numberOfBytes, 1000);
TestUtil.waitWhile(() -> recordedBytes.size() < numberOfBytes, TIMEOUT.toMillis());
}

public byte[] getRecordedBytes() {
Expand All @@ -91,7 +94,7 @@ public void streamAppended(String text, IStreamMonitor mon) {
}

public void waitForBytes(int numberOfChars) throws Exception {
TestUtil.waitWhile(() -> recordedChars.length() < numberOfChars, 1000);
TestUtil.waitWhile(() -> recordedChars.length() < numberOfChars, TIMEOUT.toMillis());
}

public String getRecordedChars() {
Expand Down

0 comments on commit 28d9767

Please sign in to comment.