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 413b15c498 Fix failing test on Windows
413b15c498 is described below
commit 413b15c498c1e4c67da14ec948dce0012e97c881
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 | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/test/org/apache/jasper/servlet/TestJspCServletContext.java
b/test/org/apache/jasper/servlet/TestJspCServletContext.java
index 3446cd8120..0e061aabf0 100644
--- a/test/org/apache/jasper/servlet/TestJspCServletContext.java
+++ b/test/org/apache/jasper/servlet/TestJspCServletContext.java
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.net.JarURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -28,6 +29,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 javax.servlet.descriptor.JspConfigDescriptor;
@@ -219,7 +221,12 @@ public class TestJspCServletContext {
URL url = context.getResource("/my file.jsp");
Assert.assertNotNull(url);
- try (InputStream is = url.openStream(); ByteArrayOutputStream out
= new ByteArrayOutputStream()) {
+ // 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();
+ ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ Assert.assertNotNull(jarFile);
int read;
byte[] buf = new byte[1024];
while ((read = is.read(buf)) >= 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]