Adding SAXParserFactory lookup under the system properties

XMLWordPrintable

      As a part of Confluence Crowd integration so as to unmarshal the response from Crowd, we are using SAXParser. Now the problem is that during this process, we create createSAXParserFactory and tries to the load the implementation class which as per specification as below(snippet from https://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance-- )
      ---------
      Obtain a new instance of a SAXParserFactory. This static method creates a new factory instance This method uses the following ordered lookup procedure to determine the SAXParserFactory implementation class to load:

      • Use the javax.xml.parsers.SAXParserFactory system property.
      • Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time.
      • Use the service-provider loading facilities, defined by the ServiceLoader class, to attempt to locate and load an implementation of the service using the default loading mechanism: the service-provider loading facility will use the current thread's context class loader to attempt to load the service. If the context class loader is null, the system class loader will be used.
      • Otherwise the system-default implementation is returned.
        Once an application has obtained a reference to a SAXParserFactory it can use the factory to configure and obtain parser instances.

      Suggestion
      Lots of threads are blocked(snippet below) on finding the specific implementation and hence probably it might help if we go ahead and add below system property for a better performance around this lookup
      -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl

      "http-nio-127.0.0.1-13045-exec-81 url:/CITnet/conflue...rces/1.0/resources" #4538 daemon prio=5 os_prio=0 tid=0x00007f6154042000 nid=0x3dc7 waiting for monitor entry [0x00007f5fe16f3000]
         java.lang.Thread.State: BLOCKED (on object monitor)
              at java.util.zip.ZipFile.getEntry(ZipFile.java:314)
              - waiting to lock <0x00000007b0f4ccb8> (a java.util.jar.JarFile)
              at java.util.jar.JarFile.getEntry(JarFile.java:240)
              at java.util.jar.JarFile.getJarEntry(JarFile.java:223)
              at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:98)
              at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:256)
              at org.apache.catalina.webresources.StandardRoot.getResourcesInternal(StandardRoot.java:327)
              at org.apache.catalina.webresources.CachedResource.validateResources(CachedResource.java:158)
              - locked <0x00000007be9eac20> (a org.apache.catalina.webresources.CachedResource)
              at org.apache.catalina.webresources.Cache.getResources(Cache.java:165)
              at org.apache.catalina.webresources.StandardRoot.getResources(StandardRoot.java:315)
              at org.apache.catalina.webresources.StandardRoot.getClassLoaderResources(StandardRoot.java:231)
              at org.apache.catalina.loader.WebappClassLoaderBase.findResources(WebappClassLoaderBase.java:991)
              at org.apache.catalina.loader.WebappClassLoaderBase.getResources(WebappClassLoaderBase.java:1086)
              at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:348)
              at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393)
              at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474)
              at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:293)
              at java.security.AccessController.doPrivileged(Native Method)
              at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289)
              at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267)
              at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127)
              at com.atlassian.security.xml.SecureXmlParserFactory.createSAXParserFactory(SecureXmlParserFactory.java:177)
              at com.atlassian.security.xml.SecureXmlParserFactory.newNamespaceAwareXmlReader(SecureXmlParserFactory.java:215)
              at com.atlassian.crowd.integration.rest.service.RestExecutor$MethodExecutor.andReceive(RestExecutor.java:375)
              at com.atlassian.crowd.integration.rest.service.RestCrowdClient.getCookieConfiguration(RestCrowdClient.java:975)
              at com.atlassian.crowd.integration.http.CrowdHttpAuthenticatorImpl.getCookieTokenKey(CrowdHttpAuthenticatorImpl.java:189)
              at com.atlassian.crowd.integration.http.CrowdHttpAuthenticatorImpl.getToken(CrowdHttpAuthenticatorImpl.java:176)
              at com.atlassian.crowd.integration.http.CacheAwareCrowdHttpAuthenticator.getToken(CacheAwareCrowdHttpAuthenticator.java:87)
              at com.atlassian.crowd.integration.seraph.CrowdAuthenticator.getUser(CrowdAuthenticator.java:399)
              at com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator.lambda$getUser$3(ConfluenceCrowdSSOAuthenticator.java:105)
              at com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator$$Lambda$2264/967485593.get(Unknown Source)
              at com.atlassian.confluence.impl.seraph.TimingAccumulator.accumulateOperation(TimingAccumulator.java:51)
              at com.atlassian.confluence.impl.seraph.AuthenticatorMetrics.measureGetUser(AuthenticatorMetrics.java:31)
              at com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator.getUser(ConfluenceCrowdSSOAuthenticator.java:105)
              at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:139)
              at com.atlassian.confluence.web.filter.ConfluenceSecurityFilter.applyFilter(ConfluenceSecurityFilter.java:40)
              at com.atlassian.confluence.web.filter.ConfluenceSecurityFilter.doFilter(ConfluenceSecurityFilter.java:29)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at com.atlassian.confluence.web.filter.ThreadLocalCacheFilter.doFilter(ThreadLocalCacheFilter.java:25)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)
              at com.atlassian.confluence.util.AbstractBootstrapHotSwappingFilter.doFilter(AbstractBootstrapHotSwappingFilter.java:35)
              at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at com.atlassian.seraph.filter.BaseLoginFilter.doFilter(BaseLoginFilter.java:148)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:39)
              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.lambda$doFilter$0(DelegatingPluginFilter.java:57)
              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$$Lambda$2245/1656605670.doFilter(Unknown Source)
              at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)
              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:62)
              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:37)
      
      

            Assignee:
            Unassigned
            Reporter:
            Saurabh Bhatia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: