Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8043929

The basic XML parser fails with a NPE or UEE if encoding is null or empty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 9
    • 8, 9
    • xml
    • None

      If encoding specified is null or empty, the basic XML parser will fail to start.

      Test:
                  String encoding = null; //or ""
                  Properties props = new Properties();
                  props.put("k1", "foo");
                  props.put("k2", "bar");
                  
                  ByteArrayOutputStream out = new ByteArrayOutputStream();
                  try {
                        props.storeToXML(out, null, encoding);
                  } catch (Exception e) {
                        //fail
                  }

      Expected:
              save the properties using default encoding (UTF-8)

      Actual:
              NullPointerException when encoding = null
              UnsupportedEncodingException when encoding = ""

            joehw Joe Wang
            joehw Joe Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: