Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-5570

URLDeploymentScanner: relies on FileInputStream finalizer - causes too many open files too easily


    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: JBossAS-4.2.2.GA
    • Fix Version/s: No Release
    • Component/s: Deployers
    • Labels:


      I'm a JavaRebel developer from ZeroTurnaround and have been debugging an issue with "Too many open files" with JBoss that we got reported against JavaRebel.

      The problem:
      Users are getting "Too many open files" exceptions when starting and then using JBoss.

      The reason:
      *) JBoss by default has configured a mbean org.jboss.deployment.scanner.URLDeploymentScanner which scans every 5 seconds for changes in the deployment descriptors
      *) The implementation does a connection = URL.openConnection() and then connection.getLastModified() to check for changes.
      *) The underlying implementation for regular files is java.io.FileInputStream
      *) The resource is not explicitly closed as FileInputStream will doit it by itself in the finalizer()
      *) Handles are freed when GC happens (finalizer logic)

      I came to this conclusion by getting the number of filehandles (lsof -p <jboss-pid>). Stepping through URLDeploymentScanner and seeing the handles grow by one after every connection.getLastModified(). In all tests the handles grow by one after this call.

      I also let the handles grow to a few thousand and then attached a debugger and after hitting a breakpoint called System.gc() on the JVM and the number of filehandles nicely went down to ~380 with my deployment folder.

      Possible solution:
      Check for the file modification date with explicit closing.

        Gliffy Diagrams


            Issue Links



                • Assignee:
                  dimitris Dimitrios Andreadis
                  toomasr Toomas Romer
                • Votes:
                  5 Vote for this issue
                  8 Start watching this issue


                  • Created: