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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b15

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              joehw Joe Wang
              Reporter:
              amadgundi Asha Madgundi
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: