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

[configuration] Invalid resource names in XMLConfiguration generate a NPE

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Bugzilla Id:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: