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

Empty ini section occurs NPE while save to writer

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.2
    • Component/s: File reloading, Format
    • Labels:
      None
    • Environment:

      OS: OS X 10.12
      JDK: 1.8

      Description

      Run following code:

      import org.apache.commons.configuration2.INIConfiguration;
      import java.io.*;
      
      public class Demo {
         public static void main(String[] args) throws Exception {
          INIConfiguration ini = new INIConfiguration();
          ini.read(new StringReader("[emptySection]"));
          ini.write(new StringWriter());
        }
      }
      

      Result:

      Exception in thread "main" java.lang.NullPointerException
      	at org.apache.commons.configuration2.INIConfiguration.writeProperty(INIConfiguration.java:458)
      	at org.apache.commons.configuration2.INIConfiguration.write(INIConfiguration.java:309)
      	at Demo.main(Demo.java:8)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vision57 yankai zhang
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: