RFR: 8231640: (prop) Canonical property storage [v14]

Jaikiran Pai jpai at openjdk.java.net
Tue Sep 14 14:12:07 UTC 2021


On Tue, 14 Sep 2021 13:28:24 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> There has been no change in how we deal with this aspect. The existing specification (stated in the `load` method) says:
>> 
>> 
>>>     * Properties are processed in terms of lines. There are two
>>>     * kinds of line, <i>natural lines</i> and <i>logical lines</i>.
>>>     * A natural line is defined as a line of
>>>     * characters that is terminated either by a set of line terminator
>>>     * characters ({@code \n} or {@code \r} or {@code \r\n})
>>>     * or by the end of the stream. A natural line may be either a blank line,
>>>     * a comment line, or hold all or some of a key-element pair. A logical
>>>     * line holds all the data of a key-element pair, which may be spread
>>>     * out across several adjacent natural lines by escaping
>>>     * the line terminator sequence with a backslash character
>>>     * {@code }.  **Note that a comment line cannot be extended
>>>     * in this manner;**
>> (emphasis on that last sentence).
>> I'll anyway go ahead and add new tests around this to be sure that this works as advertised.
>
> Oh - great - thanks - verifying by a test that it also applies to the comment specified by `java.util.Properties.storeDate` would be good.

Done. A new test `StoreReproducibilityTest#testBackSlashInStoreDateValue` has been added in the latest updated version of this PR. This test passes. Plus I checked the written out properties file, from these tests, for such values in `java.util.Properties.storeDate` and the content matches what the spec says. 
Just for quick reference - a run of that test case with the "newline-plus-backslash...." system property value (cannot paste that exact string value from that test case because GitHub editor is messing up the special characters) generates output like below:


#some user specified comment
#newline-plus-backslash\
#c=d
a=b

-------------

PR: https://git.openjdk.java.net/jdk/pull/5372


More information about the core-libs-dev mailing list