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

Properties :: storeToXML method does not throw ClassCastException when supplied non strings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 16
    • None
    • core-libs
    • b15

      Properties::storeToXML method declares that it throws ClassCastException when Properties object contains any keys or values that are not Strings:
      https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/Properties.html#storeToXML(java.io.OutputStream,java.lang.String,java.lang.String)
      The behavior is not matching spec.

      Sample Code:

      private void storeToXML_01() throws IOException {
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              Properties pr = new Properties();
              pr.put("one", "\u7532");
              pr.put(new Integer(8), 238923);
              pr.put(new Object(), new Double(1.1));
              pr.storeToXML(os, "Test", "UTF-8");
          }

      Not throwing ClassCastException.

            joehw Joe Wang
            amadgundi Asha Madgundi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: