On Thu, 20 Oct 2022 18:46:04 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

>> I would vote against this change.  Per java properties spec
>> https://github.com/openjdk/jdk/pull/10792
>> 
>> 
>> White space following the property value is not ignored, and is treated as 
>> part of the property value.
>> 
>> 
>> This change might break localization or messages where trailing whitespace 
>> is important (example: "Label: ")
>> 
>> edit: sorry, the link above is not a spec.  looking at the 
>> Properties.load(Reader) javadoc:
>> https://docs.oracle.com/javase/10/docs/api/java/util/Properties.html#load(java.io.Reader)
>> 
>> 
>> Any white space after the key is skipped; if the first non-white space 
>> character after the key is '=' or ':', then it is ignored and any white 
>> space characters after it are also skipped. All remaining characters on the 
>> line become part of the associated element string;
>
> @andy-goryachev-oracle Oh, I did not know that. Is this really how it is 
> implemented, or is there a discrepancy between the spec and the 
> implementation? The haphazard placement of trailing spaces seems to indicate 
> that they are ignored.

@magicus  : 
no, this is how Properties were working from day one.


package goryachev.research;

import java.io.IOException;
import java.io.StringReader;
import java.util.Properties;

public class TestProperties {
    public static void main(String[] args) throws IOException {
        String text = "key= value ";
        Properties p = new Properties();
        p.load(new StringReader(text));
        System.out.println("value=["  +p.getProperty("key") + "]");
    }
}


outputs:

value=[value ]

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

PR: https://git.openjdk.org/jdk/pull/10792

Reply via email to