Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-135

[configuration] Invalid resource names in XMLConfiguration generate a NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 31041

    Description

      XMLConfiguration throws a NullPointerException if an invalid resource name is
      passed to its constructor, it should throw a ConfigurationException explaining
      the issue instead.

      Fix suggested by Ben Hutchison:

      private static File resourceURLToFile(String resource) {
      URL confURL = XMLConfiguration.class.getClassLoader().getResource(resource);
      if (confURL == null)

      { confURL = ClassLoader.getSystemResource(resource); }

      if (confURL == null)
      throw new IllegalArgumentException("Resource:"resource" not found
      thru context or system classloaders.");
      return new File(confURL.getFile());
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            ebourg Emmanuel Bourg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: