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

Properties.load fails to throw IAE on malformed unicode in certain circumstances

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Throw exception as specified.
    • Interface Kind:
      Java API
    • Scope:
      Implementation

      Description

      Summary

      Change loading of properties files with malformed unicode escape sequences to always fail with IllegalArgumentException.

      Problem

      Certain sequences of properties ending with malformed unicode escape sequences can silently and erroneously be parsed to contain residual values from a preceding line in the property file. Fixing this straight forward bug could theoretically cause some property files that were previously parsed successfully (though incorrectly) without throwing an exception to instead throw an exception.

      A property file with malformed unicode sequences is specified to throw IllegalArgumentException. This happen correctly most of the time, e.g., when loading a file looking like this:

      "key=value\u00ps\n"

      But when the malformed unicode codepoint is at the end of a line and there's a preceding line with data that would have been valid had it been on the current line, the unicode codepoint might silently be parsed using the content of the preceding line. For example this properties file:

      "key1=foo\u0123\nkey2=bar\u0\n"

      Here the value of key2 will be parsed as if it was 'bar\u0123'. According to the specification, this should throw an IllegalArgumentException.

      Solution

      Fix the bug and always throw an IllegalArgumentException.

      Specification

      No specification change. The behavior is changed to adhere more strictly to the specification after bug is fixed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              redestad Claes Redestad
              Reporter:
              redestad Claes Redestad
              Reviewed By:
              Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: