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

XMLConfiguration.load may throw NPE

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Java 8 / Linux

      Description

      I expect that

          URL url = Test.class.getResource( "/Test.xml");	
          XMLConfiguration config = new XMLConfiguration();
          config.read( url.openStream());
      

      Would read the XML file. However it will throw a NPE at line 967

       private void load(InputSource source) throws ConfigurationException
          {
              try
              {
                  URL sourceURL = locator.getSourceURL(); // <- NPE here
                  if (sourceURL != null)
                  {
                      source.setSystemId(sourceURL.toString());
                  }
      

      I believe that testing for locator == null first will solve the problem as the rest of the code in the method does not appear to use it.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              claude Claude Warren
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified