Skip to content

Commit 03da7a6

Browse files
committed
Tweak server timeouts
1 parent d892f35 commit 03da7a6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.io.InputStream;
2323
import java.net.ServerSocket;
2424
import java.net.Socket;
25-
import java.time.Duration;
25+
import java.util.concurrent.TimeUnit;
2626

2727
import org.apache.commons.codec.binary.Hex;
2828
import org.apache.logging.log4j.Level;
@@ -49,6 +49,8 @@
4949
@UsingTestProperties
5050
class JsonTemplateLayoutNullEventDelimiterTest {
5151

52+
private static final int TIMEOUT_MS = 10_000;
53+
5254
private static Logger LOGGER = StatusLogger.getLogger();
5355

5456
private static TcpServer server;
@@ -95,8 +97,7 @@ public Result filter(LogEvent event) {
9597
try {
9698
Awaitility
9799
.await()
98-
.atMost(Duration.ofSeconds(10))
99-
.pollDelay(Duration.ofSeconds(1))
100+
.atMost(TIMEOUT_MS, TimeUnit.MILLISECONDS)
100101
.until(() -> server.getTotalReadByteCount() >= expectedBytes.length);
101102
} catch (final ConditionTimeoutException e) {
102103
LOGGER.info("Timeout reached while waiting for {} bytes.", expectedBytes.length);
@@ -121,10 +122,10 @@ private TcpServer(final int port) throws IOException {
121122
this.serverSocket = new ServerSocket(port);
122123
this.outputStream = new ByteArrayOutputStream();
123124
serverSocket.setReuseAddress(true);
124-
serverSocket.setSoTimeout(5_000);
125+
serverSocket.setSoTimeout(TIMEOUT_MS);
125126
setDaemon(true);
126127
start();
127-
LOGGER.info("TcpServer started on port {}.", port);
128+
LOGGER.info("TcpServer started on port {}.", serverSocket.getLocalPort());
128129
}
129130

130131
@Override

0 commit comments

Comments
 (0)