On 30/06/2026 20:53, Rémy Maucherat wrote:

So it should be possible to refactor it to:

     public long getFileLastModified(String path, boolean virtual)
throws IOException {
         long lastModified = 0;
         URLConnection urlConnection = null;
         try {
             urlConnection = getURLConnection(path, virtual);
             try (InputStream _ = urlConnection.getInputStream()) {
                 lastModified = urlConnection.getLastModified();
             } catch (Exception e) {
                 ExceptionUtils.handleThrowable(e);
             }
         } catch (IOException ignore) {
             // Ignore this. It will always fail for non-file based includes
         }
         return lastModified;
     }
> > Do your Claude actually like the code pattern we have in Tomcat right
now ? Somehow I doubt it.
I haven't been asking it about implementation detail.

At the moment, it seems to be more concerned about code duplication. That is mostly fixable although we'd need a couple of copies.

There is also a query whether the fd leak is real or not. It certainly was real when these fixes were originally written. I suspect it might not be considering the more extreme edge cases where the resource may be in a JAR packaged in another JAR/WAR. If I had (a lot more) time, I'd run some tests to look into that.

Mark

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

Reply via email to