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.
- csr of
-
JDK-8224240 Properties.load fails to throw IAE on malformed unicode in certain circumstances
- Resolved