Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4986

Race condition reloading config results in actions not found

    XMLWordPrintableJSON

    Details

      Description

      Issue only occurs when the following xml configuration is present :

      “struts.configuration.xml.reload” is set to true .

       

      The reload flag is supposed to reload the xml configuration when it changes. To this end it calls the synchronized method com.opensymphony.xwork2.config.impl.DefaultConfiguration::reloadContainer. This clears out the packageContext map. The issue is that this operation is not thread safe as none of the other accessors of this map (for example com.opensymphony.xwork2.config.impl.DefaultConfiguration::getPackageConfigs which is the cause of the disappearing actions) is not synchronized .

      A solution would be totally rebuild the context into a separate temporary object and reassign it at the end.

       

       

      To make matters worse is that this reloading happens on almost every single request due to some other race condition which I haven't figured out yet.

      • For some reason DefaultFileManagerFactory (which is not a singleton) fails to properly set DefaultFileManagerFactory::setReloadingConfigs from the XML thus reloadConfigs is false which causes DefaultFileManager::setReloadingConfigs to be false, which means that when struts doesn’t monitor files (DefaultFileManager::monitorFile) and the files cache is empty.
      • Now this would work, but the code that calls DefaultFileManager::fileNeedsReloading and DefaultFileManager::loadFile is a different instance of this class, where the first one has reloadingConfigs set to true, and in the second one to false.
      • Somewhere in XWorkConverter::SetFileManagerFactory > DefaultFileManagerFactory::getFileManager > DefaultFileManager::setReloadingConfigs using the same stack (at least to this level) the configuration is not read properly. 

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                yasserzamani Yasser Zamani
                Reporter:
                tompom Tamás Faragó
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: