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 477e7f2131 Revert FileURLConnection changes - it does open an 
InputStream
477e7f2131 is described below

commit 477e7f2131e29e1b7e54ae4930e56c53abee2951
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jul 6 12:21:01 2026 +0100

    Revert FileURLConnection changes - it does open an InputStream
---
 java/org/apache/tomcat/util/buf/CloseableURLConnection.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/CloseableURLConnection.java 
b/java/org/apache/tomcat/util/buf/CloseableURLConnection.java
index fe54a11cd7..6b1d6d7c54 100644
--- a/java/org/apache/tomcat/util/buf/CloseableURLConnection.java
+++ b/java/org/apache/tomcat/util/buf/CloseableURLConnection.java
@@ -146,15 +146,12 @@ public final class CloseableURLConnection extends 
URLConnection implements AutoC
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
             }
-        } else if 
(connection.getClass().getName().equals("sun.net.www.protocol.file.FileURLConnection"))
 {
+        } else if (!(connection instanceof HttpURLConnection)) {
             /*
-             * Internal JDK class so have to check by default name. If a JDK 
uses another name it will be handled by the
-             * final block.
+             * sun.net.www.protocol.file.FileURLConnection is known to open an 
InputStream for files.
              *
-             * NO-OP - known not to open a stream to read metadata
+             * Other cases could have used a stream as a side effect, possibly 
causing file locking.
              */
-        } else if (!(connection instanceof HttpURLConnection)) {
-            // Other cases could have used a stream as a side effect, possibly 
causing file locking.
             try (@SuppressWarnings("unused") InputStream is = 
connection.getInputStream()) {
                 // Explicitly close the InputStream to release its native 
resources.
             } catch (Throwable t) {


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

Reply via email to