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

Don't add JBossFileManager as a possible FileManager when not on JBoss

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.5.10
    • Fix Version/s: 2.5.12
    • Component/s: Core
    • Labels:
      None

      Description

      When the application starts and there is no FileManager specified as initParam, the JBossFileManager gets added.

      This results in the check happening everytime a FileManager is requested.
      (When turning on logging, i can see it happening 12 times when starting a simple application)

      org.apache.struts2.dispatcher.Dispatcher
      ...
          private void init_FileManager() throws ClassNotFoundException {
              if (initParams.containsKey(StrutsConstants.STRUTS_FILE_MANAGER)) {
                  ...
              } else {
                  // add any other Struts 2 provided implementations of FileManager
                  configurationManager.addContainerProvider(new FileManagerProvider(JBossFileManager.class, "jboss"));
              }
              ...
          }
      ...
      
      com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory
          private FileManager lookupFileManager() {
              Set<String> names = container.getInstanceNames(FileManager.class);
              ...
              for (FileManager fm : internals) {
                  if (fm.support()) {
                      return fm;
                  }
              }
              return null;
          }
      

      My suggestion would be to not add it if it's not supported.

      I don't know what the best way to do this would be.

      The possibility i was thinking of so far involves the following:

      • Creating a seperate utility class to check if it can support it
        • perhaps a public static innerclass of JBossFileManager with public static method(s) to check it?
        • or a seperate class (although i think this might be awkward)
      • adding a test around adding the JBossFileManager to only do it when it could be supported.

      additional information:

      • log messages were noticed by adjusting the log4j2 configuration in the form-processing application from struts-examples and starting it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lukaszlenart Lukasz Lenart
                Reporter:
                sdutry Stefaan Dutry
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: