[ 
https://issues.apache.org/jira/browse/WW-4302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lukasz Lenart updated WW-4302:
------------------------------

    Description: 
In XmlConfigurationProvider, the field loadedFileUrls contains the xml files 
loaded. The loaded files will be checked if they are modified for configuration 
reloading.
{code:java}
    public boolean needsReload() {

        for (String url : loadedFileUrls) {
            if (fileManager.fileNeedsReloading(url)) {
                return true;
            }
        }
        return false;
    }
{code}
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. I send a pull request in github: 
https://github.com/apache/struts/pull/6, and I test it running well.

  was:
In XmlConfigurationProvider, the field loadedFileUrls contains the xml files 
loaded. The loaded files will be checked if they are modified for configuration 
reloading.

    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. I send a pull request in github: 
https://github.com/apache/struts/pull/6, and I test it running well.


> XmlConfigurationProvider.loadedFileUrls only contains the last one of urls 
> with same file name
> ----------------------------------------------------------------------------------------------
>
>                 Key: WW-4302
>                 URL: https://issues.apache.org/jira/browse/WW-4302
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Configuration
>    Affects Versions: 2.3.16.1
>            Reporter: Liang Liu
>            Priority: Minor
>              Labels: patch
>             Fix For: 2.3.17
>
>
> In XmlConfigurationProvider, the field loadedFileUrls contains the xml files 
> loaded. The loaded files will be checked if they are modified for 
> configuration reloading.
> {code:java}
>     public boolean needsReload() {
>         for (String url : loadedFileUrls) {
>             if (fileManager.fileNeedsReloading(url)) {
>                 return true;
>             }
>         }
>         return false;
>     }
> {code}
> 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. I send a pull request in github: 
> https://github.com/apache/struts/pull/6, and I test it running well.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to