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

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

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


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

commit 310617ec6ed4e6d7b993044d8b0ce27c36f8c132
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.