Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3545

FACELETS_REFRESH_PERIOD > 0 + .xhtml in .jar = Too many open files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.7
    • 2.0.14, 2.1.8
    • General
    • None
    • myfaces trunk

    Description

      this is a classic one:
      https://issues.apache.org/jira/browse/TRINIDAD-73
      https://issues.apache.org/jira/browse/MYFACES-1982

      From http://www.mail-archive.com/wicket-user@lists.sourceforge.net/msg20937.html:

      " .... It's a bug in Sun's JarURLConnection. The workaround should solve the problems even in
      development mode.

      When you open an URL connection to an entry in a jar, you get a
      JarURLConnection. The JarURLConnection in the package
      sun.net.www.protocol.jar has an internal field

      /* the url connection for the JAR file */
      private URLConnection jarFileURLConnection;

      which you cannot access in any way. When you ask for the last modified
      time, the JarURLConnection will ask for the header field
      "last-modified", which in turn will ask the jarFileURLConnection for the
      that header field, which in turn will cause the initializeHeaders() call
      in FileURLConnection, which in turn calls connect() and opens the file
      (even though for the last modified header that is quite unnecessary).
      The way to close the file is to call getInputStream().close() on the
      jarFileURLConnection field, but unfortunately you can't since it is hidden.

      There is a very simple workaround though. In code:

      URL url = new URL("jar:file:jarfile.jar!Entry.class");
      URLConnection connection = url.openConnection();
      if (connection instanceof JarURLConnection)

      { JarURLConnection jarUrlConnection = (JarURLConnection) connection; URL jarFileUrl = jarUrlConnection.getJarFileURL(); URLConnection jarFileConnection = jarFileUrl.openConnection(); long lastModified = jarFileConnection.getLastModified(); jarFileConnection.getInputStream().close(); System.out.println("last modified=" + new Date(lastModified)); }

      ... "

      This little hack is not done in myfaces DefaultFaceletFactory and FaceletCacheImpl.

      Simple workaround is: javax.faces.FACELETS_REFRESH_PERIOD=0 in Development stage

      Attachments

        1. MYFACES-3545.patch
          3 kB
          Martin Kočí

        Activity

          People

            markoc50 Martin Kočí
            markoc50 Martin Kočí
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: