Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-344

Deadlock during refresh properties

    XMLWordPrintableJSON

Details

    Description

      Hi
      Commons configurations get itself stuck in deadlock when refreshing
      properties using Managed reloading strategy. It seems to me it get stuck
      because of fireEvent in reload method. Another access grabs lock on
      synchronized (getNodeCombiner()) when trying to rebuild but Combined
      configuration is one of the listeners for event es well and it gets
      stuck when processing invalidate. Can anyone suggest quick fix please?
      Relevant information follows.
      Thanks
      Pavel

      Configuration:

      <configuration> 
        <override>
          <system/>    
          <properties fileName="gsxweb.properties" throwExceptionOnMissing="false"
             config-name="gsxweb" config-optional="false" listDelimiter="|">
             <reloadingStrategy config-class="org.apache.commons.configuration.reloading.ManagedReloadingStrategy"/>      
          </properties>    
        </override> 
      </configuration>
      

      Our Reload code:

              int ln = combinedConfiguration.getNumberOfConfigurations();
              int reloaded = 0;
              for (int i = 0; i < ln; i++) {
                  Configuration conf = combinedConfiguration.getConfiguration(i);
                  if (conf instanceof PropertiesConfiguration) {
                      ManagedReloadingStrategy strat = null;
                      ReloadingStrategy strategy = ((PropertiesConfiguration) conf).getReloadingStrategy();
                      //refresh if managed strategy
                      if (strategy instanceof ManagedReloadingStrategy) {
                          ((ManagedReloadingStrategy) strategy).refresh();
                      //reload if file changed strategy    
                      } else if (strategy instanceof FileChangedReloadingStrategy) {                    
                          ((PropertiesConfiguration) conf).reload();
                      }
                      reloaded++;
                  }
              }
      
      Stack trace of deadlock threads
      Name: http-10980-1
      State: BLOCKED on
      org.apache.commons.configuration.tree.OverrideCombiner@8511bb owned by:
      http-10980-6
      Total blocked: 154  Total waited: 2
      
      Stack trace: 
      org.apache.commons.configuration.CombinedConfiguration.invalidate(CombinedConfiguration.java:474)
      org.apache.commons.configuration.CombinedConfiguration.configurationChanged(CombinedConfiguration.java:488)
      org.apache.commons.configuration.event.EventSource.fireEvent(EventSource.java:249)
      org.apache.commons.configuration.AbstractFileConfiguration.fireEvent(AbstractFileConfiguration.java:911)
      org.apache.commons.configuration.AbstractFileConfiguration.reload(AbstractFileConfiguration.java:828)
         - locked java.lang.Object@127e34c
      org.apache.commons.configuration.AbstractFileConfiguration.isEmpty(AbstractFileConfiguration.java:927)
      org.apache.commons.configuration.reloading.ManagedReloadingStrategy.refresh(ManagedReloadingStrategy.java:91)
      com.gsx.properties.PropertyProviderImpl.reset(PropertyProviderImpl.java:203)
         - locked java.lang.Class@109bcda
      org.apache.jsp.test.testPropertyProvider_jsp._jspService(testPropertyProvider_jsp.java:60)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      
      
      Name: http-10980-6
      State: BLOCKED on java.lang.Object@127e34c owned by: http-10980-1
      Total blocked: 115  Total waited: 2
      
      Stack trace: 
      org.apache.commons.configuration.AbstractFileConfiguration.reload(AbstractFileConfiguration.java:814)
      org.apache.commons.configuration.AbstractFileConfiguration.getKeys(AbstractFileConfiguration.java:939)
      org.apache.commons.configuration.ConfigurationUtils.copy(ConfigurationUtils.java:139)
      org.apache.commons.configuration.ConfigurationUtils.convertToHierarchical(ConfigurationUtils.java:199)
      org.apache.commons.configuration.CombinedConfiguration
      $ConfigData.getTransformedRoot(CombinedConfiguration.java:794)
      org.apache.commons.configuration.CombinedConfiguration.constructCombinedNode(CombinedConfiguration.java:653)
      org.apache.commons.configuration.CombinedConfiguration.getRootNode(CombinedConfiguration.java:504)
         - locked
      org.apache.commons.configuration.tree.OverrideCombiner@8511bb
      org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:925)
      org.apache.commons.configuration.HierarchicalConfiguration.getProperty(HierarchicalConfiguration.java:327)
      org.apache.commons.configuration.CombinedConfiguration.getProperty(CombinedConfiguration.java:578)
      org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(AbstractConfiguration.java:1155)
      org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1034)
      org.apache.jsp.test.testPropertyProvider_jsp._jspService(testPropertyProvider_jsp.java:69)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      

      Attachments

        Issue Links

          Activity

            People

              oheger Oliver Heger
              palko Pavel Savara
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: