(tomcat) branch 9.0.x updated: Add re-try attempt after observing likely timing related test failures

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <[email protected]>
This is an automated email from the ASF dual-hosted git repository.

markt-asf 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 80c51d848f Add re-try attempt after observing likely timing related test failures
80c51d848f is described below

commit 80c51d848f5c8e0ab1d3f11862bdc89c51210c32
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Aug 12 12:10:14 2026 +0100

    Add re-try attempt after observing likely timing related test failures
---
 .../EncryptionInterceptorBaseTest.java             | 26 +++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/catalina/tribes/group/interceptors/EncryptionInterceptorBaseTest.java b/test/org/apache/catalina/tribes/group/interceptors/EncryptionInterceptorBaseTest.java
index d455f5660f..970a451f6c 100644
--- a/test/org/apache/catalina/tribes/group/interceptors/EncryptionInterceptorBaseTest.java
+++ b/test/org/apache/catalina/tribes/group/interceptors/EncryptionInterceptorBaseTest.java
@@ -34,6 +34,7 @@ import org.apache.catalina.tribes.group.ChannelInterceptorBase;
 import org.apache.catalina.tribes.group.InterceptorPayload;
 import org.apache.catalina.tribes.io.ChannelData;
 import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.tomcat.util.ExceptionUtils;
 
 public class EncryptionInterceptorBaseTest {
 
@@ -56,9 +57,28 @@ public class EncryptionInterceptorBaseTest {
 
     @AfterClass
     public static void cleanup() {
-        File f = new File(MESSAGE_FILE);
-        if (f.isFile()) {
-            Assert.assertTrue(f.delete());
+        int attempts = 0;
+        int maxAttempts = 2;
+        while (attempts < maxAttempts) {
+            attempts++;
+            try {
+                File f = new File(MESSAGE_FILE);
+                if (f.isFile()) {
+                    Assert.assertTrue(f.delete());
+                }
+            } catch (Throwable t) {
+                ExceptionUtils.handleThrowable(t);
+                if (attempts < maxAttempts) {
+                    // Brief delay before re-try
+                    try {
+                        Thread.sleep(50);
+                    } catch (InterruptedException e) {
+                        // Ignore. The delay will just be shorter than expected.
+                    }
+                } else {
+                    throw t;
+                }
+            }
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.