(tomcat) branch 11.0.x updated: Revert FileURLConnection changes - it does open an InputStream

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <[email protected]>
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 5e38fe4422 Revert FileURLConnection changes - it does open an InputStream
5e38fe4422 is described below

commit 5e38fe44227ab9b154794fa12a2b15999e3f9996
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) {
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.