struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject struts.configuration.xml.reload=true always reloads files
Date Wed, 26 Dec 2018 08:32:12 GMT
struts.configuration.xml.reload=true always reloads files because when
DefaultFileManager checks the revision it is always null.  The initial
@inject seems to be out of sequence.

DefaultFileManagerFactory.getFileManager() is called from XWorkConverter
which instantiates DefaultFileManager first:

(See DefaultFileManagerFactory.getFileManager())

@Inject
    public void setFileManagerFactory(FileManagerFactory
fileManagerFactory) {
        this.fileManager = fileManagerFactory.getFileManager();
    }

The DefaultFileManager with not monitor the files as reloadingConfigs =
false.

com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory is then @injected
with reloadingConfigs = true.

@Inject(value = StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, required =
false)
    public void setReloadingConfigs(String reloadingConfigs) {
        this.reloadingConfigs = Boolean.parseBoolean(reloadingConfigs);
    }

When it checks to reload the files using the revision it will always be
null as reloadingConfigs = false when initially created in XWorkConverter,
so will reload the files.

Some testing, and the only way seems to drop the check on reloadingConfigs
and always monitor the files in DefaultFileManager :

public InputStream loadFile(URL fileUrl) {
        if (fileUrl == null) {
            return null;
        }
        InputStream is = openFile(fileUrl);
        //if (reloadingConfigs) {
            monitorFile(fileUrl);
        //}
        return is;
    }

Adding an @Inject(value = StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD,
required = false) to DefaultFileManager does not work as its too far down
the @inject sequence.

Maybe there is a sequence thing for the @inject to do the alter the order
and do DefaultFileManagerFactory first?

Cheers Greg

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message