This is an automated email from the ASF dual-hosted git repository. rjung pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new be21363d1e Short sleep in unit test should suffice, but allow for lonhger ones also be21363d1e is described below commit be21363d1e22ab07dc616e03363e6b03b6d13215 Author: Rainer Jung <rainer.j...@kippdata.de> AuthorDate: Fri Apr 28 13:01:59 2023 +0200 Short sleep in unit test should suffice, but allow for lonhger ones also --- .../org/apache/catalina/valves/TestAccessLogValve.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/org/apache/catalina/valves/TestAccessLogValve.java b/test/org/apache/catalina/valves/TestAccessLogValve.java index 74a6b85f45..6a3eaf71f0 100644 --- a/test/org/apache/catalina/valves/TestAccessLogValve.java +++ b/test/org/apache/catalina/valves/TestAccessLogValve.java @@ -55,7 +55,8 @@ public class TestAccessLogValve extends TomcatBaseTest { private static Log log = LogFactory.getLog(TestAccessLogValve.class); // Requests can return in the client before log() has been called - private static final long SLEEP = 10; + private static final long SLEEP = 2; + private static final long SLEEP_MAX = 100; private static final String TEXT_TYPE = "text"; private static final String JSON_TYPE = "json"; @@ -309,12 +310,17 @@ public class TestAccessLogValve extends TomcatBaseTest { reqHead.put(REQUEST_HEADER, testHeaders); int status = getUrl(url, out, reqHead, resHead); Assert.assertEquals(HttpServletResponse.SC_OK, status); - try { - Thread.currentThread().sleep(SLEEP); - } catch (InterruptedException ex) { - log.error("Exception during sleep", ex); - } + long startWait = System.currentTimeMillis(); String result = writer.toString(); + while ("".equals(result) && System.currentTimeMillis() - startWait < SLEEP_MAX) { + try { + Thread.currentThread().sleep(SLEEP); + } catch (InterruptedException ex) { + log.error("Exception during sleep", ex); + } + result = writer.toString(); + } + Assert.assertFalse("Access log line empty after " + (System.currentTimeMillis() - startWait) + " milliseconds", "".equals(result)); boolean matches = Pattern.matches(resultMatch, result); if (!matches) { log.error("Resulting log line '" + result + "' does not match '" + resultMatch + "'"); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org