Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1338

File descriptor leak cause JarURLConnection.getLastModified()

XMLWordPrintable

    • Hide

      1. Startup WildFly and count initial file descriptor of release-stream-2.9.15.Final-resources.jar

      ./standalone.sh
      lsof -p <java pid> | grep release-stream | wc -l 
      2
      

      2. Web browser access management console http://localhost:9990/
      3. login
      4. After login, re-count file descriptor

      lsof -p <java pid> | grep release-stream | wc -l
      15
      

      5. Clear browser cache and access management console again http://localhost:9990/
      6. Count file descriptor, increate 26 file handler from the previous.

      lsof -p <java pid> | grep release-stream | wc -l
      41
      

      Debugging on File Leak Detector(http://file-leak-detector.kohsuke.org), following indicate java.net.URLConnection.getLastModified() open file handle, but never close it until gc.

      #86 /home/test/wildfly-12.0.0.Final/modules/system/layers/base/org/jboss/as/console/main/release-stream-2.9.15.Final-resources.jar by thread:management task-1 on Sat Apr 21 13:19:19 JST 2018
              at java.io.FileInputStream.<init>(FileInputStream.java:139)
              at java.io.FileInputStream.<init>(FileInputStream.java:93)
              at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
              at sun.net.www.protocol.file.FileURLConnection.initializeHeaders(FileURLConnection.java:110)
              at sun.net.www.protocol.file.FileURLConnection.getHeaderField(FileURLConnection.java:146)
              at sun.net.www.protocol.jar.JarURLConnection.getHeaderField(JarURLConnection.java:230)
              at java.net.URLConnection.getHeaderFieldDate(URLConnection.java:654)
              at java.net.URLConnection.getLastModified(URLConnection.java:559)
              at io.undertow.server.handlers.resource.URLResource.openConnection(URLResource.java:91)
              at io.undertow.server.handlers.resource.URLResource.getLastModified(URLResource.java:75)
              at io.undertow.server.handlers.resource.ResourceHandler$1.handleRequest(ResourceHandler.java:255)
              at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
              at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
              at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
              at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
              at java.lang.Thread.run(Thread.java:748)
      
      Show
      1. Startup WildFly and count initial file descriptor of release-stream-2.9.15.Final-resources.jar ./standalone.sh lsof -p <java pid> | grep release-stream | wc -l 2 2. Web browser access management console http://localhost:9990/ 3. login 4. After login, re-count file descriptor lsof -p <java pid> | grep release-stream | wc -l 15 5. Clear browser cache and access management console again http://localhost:9990/ 6. Count file descriptor, increate 26 file handler from the previous. lsof -p <java pid> | grep release-stream | wc -l 41 Debugging on File Leak Detector( http://file-leak-detector.kohsuke.org ), following indicate java.net.URLConnection.getLastModified() open file handle, but never close it until gc. #86 /home/test/wildfly-12.0.0.Final/modules/system/layers/base/org/jboss/as/console/main/release-stream-2.9.15.Final-resources.jar by thread:management task-1 on Sat Apr 21 13:19:19 JST 2018 at java.io.FileInputStream.<init>(FileInputStream.java:139) at java.io.FileInputStream.<init>(FileInputStream.java:93) at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90) at sun.net.www.protocol.file.FileURLConnection.initializeHeaders(FileURLConnection.java:110) at sun.net.www.protocol.file.FileURLConnection.getHeaderField(FileURLConnection.java:146) at sun.net.www.protocol.jar.JarURLConnection.getHeaderField(JarURLConnection.java:230) at java.net.URLConnection.getHeaderFieldDate(URLConnection.java:654) at java.net.URLConnection.getLastModified(URLConnection.java:559) at io.undertow.server.handlers.resource.URLResource.openConnection(URLResource.java:91) at io.undertow.server.handlers.resource.URLResource.getLastModified(URLResource.java:75) at io.undertow.server.handlers.resource.ResourceHandler$1.handleRequest(ResourceHandler.java:255) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) at java.lang.Thread.run(Thread.java:748)

      Repeat web management console login and browser cache clear, every time open static resource of web console module following jar, don't close it until run gc.

      wildfly-12.0.0.Final/modules/system/layers/base/org/jboss/as/console/main/release-stream-2.9.15.Final-resources.jar
      

      It is likely cause call java.net.URLConnection.getLastModified() in io.undertow.server.handlers.resource.URLResource.getLastModified().
      JarURLConnection.getLastModified() cause file handler leak.

      For more information https://bugs.openjdk.java.net/browse/JDK-6956385.

            sdouglas1@redhat.com Stuart Douglas
            norito.agetsuma 宜人 上妻 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: