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

File descriptor leak cause JarURLConnection.getLastModified()

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.0.4.Final
    • Component/s: Core
    • Labels:
      None
    • Environment:

      CentOS Linux release 7.4.1708
      OpenJDK 1.8.0_161
      WildFly 12.0.0.Final

    • Steps to Reproduce:
      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)
    • Bugzilla Update:
      Perform

      Description

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swd847 Stuart Douglas
                  Reporter:
                  n-agetsuma Norito Agetsuma
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: