Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8055787

Get rid off java.net.URL.equals() calls in deploy code.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P3
    • 9
    • 6, 7, 8, 9
    • deploy

    Description

      Comparing two java.net.URL objects using URL.equals(URL o) method results in HTTP connection
      could be made to request crossdomain.xml file that along with performance degradation could also result in some cases in deadlock if the applet creates additional threads. See the typical stack below:

      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:111)
      at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:146)
      at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:176)
      at com.sun.deploy.net.CrossDomainXML$2.run(CrossDomainXML.java:364)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.deploy.net.CrossDomainXML.check(CrossDomainXML.java:354)
      at com.sun.deploy.net.CrossDomainXML.check(CrossDomainXML.java:148)
      - locked <10f935988> (a java.lang.Class for com.sun.deploy.net.CrossDomainXML)
      at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Applet2SecurityManager.java:513)
      at java.net.InetAddress.getAllByName0(InetAddress.java:1146)
      at java.net.InetAddress.getAllByName(InetAddress.java:1084)
      at java.net.InetAddress.getAllByName(InetAddress.java:1020)
      at java.net.InetAddress.getByName(InetAddress.java:970)
      at java.net.URLStreamHandler.getHostAddress(URLStreamHandler.java:420)
      - locked <107adcaa0> (a sun.net.www.protocol.http.Handler)
      at java.net.URLStreamHandler.hostsEqual(URLStreamHandler.java:439)
      at java.net.URLStreamHandler.sameFile(URLStreamHandler.java:396)
      at java.net.URLStreamHandler.equals(URLStreamHandler.java:316)
      at java.net.URL.equals(URL.java:842)

      There are 2 monitors involved:
      1) synchronized method java.net.URLStreamHandler.hostsEqual()
      2) synchronized method sun.plugin2.applet.Plugin2ClassLoader.loadClass()

      And in different threads the order in which these locks are acquired could be different.

      The deploy code needs to be revised for usage of java.net.URL objects in collections and in testing the equivalence of object with equals() method. These places needs to be changes to use string representation of URL as a keys in collection or when comparing 2 URLs.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dtitov Daniil Titov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: