Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-135

[configuration] Invalid resource names in XMLConfiguration generate a NPE

    Details

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

      Operating System: All
      Platform: All

      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());
      }

        Activity

        Emmanuel Bourg created issue -
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 31041 12341690
        Henri Yandell made changes -
        Key COM-1538 CONFIGURATION-135
        Affects Version/s Nightly Builds [ 12311648 ]
        Component/s Configuration [ 12311107 ]
        Project Commons [ 12310458 ] Commons Configuration [ 12310467 ]
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311710 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development