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

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <178653302189.1299808.8293138241406496210@gitbox3-he-fi.apache.org>
This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new a50643fcb3 Add re-try attempt after observing likely timing related test failures
a50643fcb3 is described below

commit a50643fcb3a3b0233328b90267fd160601c6f048
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 c3db40dc28..124ea16b9e 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.