GitHub user aafly opened a pull request:

    https://github.com/apache/struts/pull/6

    loadedFileUrls only contains the last one of urls with same file name

    In XmlConfigurationProvider, the field `loadedFileUrls` contains the xml 
files loaded. The loaded files will be checked if they are modified for 
configuration reloading.
    ```java
        public boolean needsReload() {
    
            for (String url : loadedFileUrls) {
                if (fileManager.fileNeedsReloading(url)) {
                    return true;
                }
            }
            return false;
        }
    ```
    But in method `private List<Document> loadConfigurationFiles(String 
fileName, Element includeElement) `, after the `while (urls.hasNext())` loop, 
the variable `url` is assigned by the last one of urls with same file name.
    
    So when `loadedFileUrls.add(url.toString());` is called in the `for 
(Document doc : docs)` loop, only *THE LAST ONE* is added to  loadedFileUrls.
    
    I wrote a demo. I set `<constant name="struts.configuration.xml.reload" 
value="true"/>
    `.  I wrote two configuration files: `struts-plugin.xml` and 
`struts-biz.xml` in my web project. I use struts plugins such as 
`struts-spring-plugin`, `struts-json-plugin` and so on. 
    
    The reloading works when I changed the file `struts-biz.xml` in my project. 
But it does not work when I changed `struts-plugin.xml` in my project. I debug 
XmlConfigurationProvider and see  only the `struts-plugin.xml` in 
struts-spring-plugin is contained in loadedFileUrls.
    
    I tried to fix it by moving the `loadedFileUrls.add(url.toString());` into 
the  `while (urls.hasNext())` loop.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aafly/struts develop

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/struts/pull/6.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #6
    
----
commit e80658d098b1af7101d4bb71db3b25923ebcd302
Author: liang.liu <liang....@dianping.com>
Date:   2014-03-17T08:23:43Z

    Bugfix: loadedFileUrls only contains the last one of urls with same 
filename in XmlConfigurationProvider

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org

Reply via email to