Properties file evaluator and error message handler

XMLWordPrintable

      NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? See the corresponding suggestion.

      Presently we do not have a single Parser Factory that would take care of processing of all of the .properties files required to configure Confluence.

      For example the {{ DefaultBootstrapManager.upgradeHSQL() }} simply loads the .properties files via 'FileInputStream' into the 'Properties' object as a hash table of 'keys' and 'values'. This seems very neat and efficient, yet we do not implement a specific error checking on individual entries. ( not always )

      Hence, if in this example the confluencedb.properties file is corrupted for whatever reason (values missing), there is no notification provided of this corruption for the user. Instead you see a similar error as per the screenshot.

      Say the 'version' tag is missing? Or is set to a 'string' ?

        Properties p = new Properties();
        String propertiesPath = homeLocator.getHomePath() + "/database/confluencedb.properties";
        p.load(new FileInputStream(new File(propertiesPath)));
      
        String versionString = p.getProperty("version");
      
        versionString = versionString.substring(0, versionString.indexOf('.') + 2);
        double currentVersion = Double.parseDouble(versionString);
      

      This would generate a run time NPE exception which is not indicative to customer re the actual error in the confluencedb.properties file.

      Proposed Solution:

      • Use the .properties file parser to create a Properties object (as presently implemented)
      • Add specific set of classes to handle each individual Properties objects (hash tables of the actual .properties file)
      • Allow for i18n - create a separate or common error_message.properties files that would contain a specific set of customised exception messages (error message lib)
      • Allow for resolving some of the corrupted configuration issues by correcting the invalid/null values and notifying the users about it too

      Hence in the example above I could nicely use the lets call it ConfluenceDBPropertiesHandler.class - can think of a better name

      ...pseudocode...

       
      -  create a new ConfluenceDBPropertiesHandler  call it 'handler'
      -  pass the confluencedb.properties files to it
      -  let it process it (notify errors, i18n, default corrective values ...)
      -  call a valid() function on it or similar to get the status of the properties file (corrections would be performed within that class)
      - if all good - proceed ... 
      

      Hence if the version tag is missing, I could add it and print out notification of the error and correction too.

              Assignee:
              Unassigned
              Reporter:
              Ivan Benko [Atlassian]
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: