You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/10/20 12:00:53 UTC
[logging-log4j2] 02/02: Tweak server timeouts
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 03da7a6c9b0aa11d4d52c5a71ea7e67fff7d720c
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Fri Oct 20 14:00:43 2023 +0200
Tweak server timeouts
---
.../json/JsonTemplateLayoutNullEventDelimiterTest.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
index a163e54aa7..b8d90e9da1 100644
--- a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
+++ b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
-import java.time.Duration;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.codec.binary.Hex;
import org.apache.logging.log4j.Level;
@@ -49,6 +49,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@UsingTestProperties
class JsonTemplateLayoutNullEventDelimiterTest {
+ private static final int TIMEOUT_MS = 10_000;
+
private static Logger LOGGER = StatusLogger.getLogger();
private static TcpServer server;
@@ -95,8 +97,7 @@ class JsonTemplateLayoutNullEventDelimiterTest {
try {
Awaitility
.await()
- .atMost(Duration.ofSeconds(10))
- .pollDelay(Duration.ofSeconds(1))
+ .atMost(TIMEOUT_MS, TimeUnit.MILLISECONDS)
.until(() -> server.getTotalReadByteCount() >= expectedBytes.length);
} catch (final ConditionTimeoutException e) {
LOGGER.info("Timeout reached while waiting for {} bytes.", expectedBytes.length);
@@ -121,10 +122,10 @@ class JsonTemplateLayoutNullEventDelimiterTest {
this.serverSocket = new ServerSocket(port);
this.outputStream = new ByteArrayOutputStream();
serverSocket.setReuseAddress(true);
- serverSocket.setSoTimeout(5_000);
+ serverSocket.setSoTimeout(TIMEOUT_MS);
setDaemon(true);
start();
- LOGGER.info("TcpServer started on port {}.", port);
+ LOGGER.info("TcpServer started on port {}.", serverSocket.getLocalPort());
}
@Override