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 3cd26c4cdb Fix failing test on Windows
3cd26c4cdb is described below

commit 3cd26c4cdb66b665027ed4dc9cd3124e94e66d20
Author: Mark Thomas <[email protected]>
AuthorDate: Sat Nov 7 15:00:53 2026 +0000

    Fix failing test on Windows
    
    Co-authored by: Claude / Sonnet 5.5
---
 test/org/apache/jasper/servlet/TestJspCServletContext.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/org/apache/jasper/servlet/TestJspCServletContext.java 
b/test/org/apache/jasper/servlet/TestJspCServletContext.java
index 95c2a8e6d2..dc95199cc4 100644
--- a/test/org/apache/jasper/servlet/TestJspCServletContext.java
+++ b/test/org/apache/jasper/servlet/TestJspCServletContext.java
@@ -18,6 +18,7 @@ package org.apache.jasper.servlet;
 
 import java.io.File;
 import java.io.InputStream;
+import java.net.JarURLConnection;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -25,6 +26,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
 
 import jakarta.servlet.descriptor.JspConfigDescriptor;
@@ -243,7 +245,11 @@ public class TestJspCServletContext {
 
             URL url = context.getResource("/my file.jsp");
             Assert.assertNotNull(url);
-            try (InputStream is = url.openStream()) {
+            // The JarURLConnection caches the JarFile. Close it once finished 
else, on Windows, the open file prevents
+            // the JAR being deleted during clean-up.
+            JarURLConnection connection = (JarURLConnection) 
url.openConnection();
+            try (JarFile jarFile = connection.getJarFile(); InputStream is = 
connection.getInputStream()) {
+                Assert.assertNotNull(jarFile);
                 Assert.assertEquals("<jsp/>",
                         new String(is.readAllBytes(), StandardCharsets.UTF_8));
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to