[sonar-dev] About sonar.properties in the sonarqube distribution...

classic Classic list List threaded Threaded
7 messages Options
fge
Reply | Threaded
Open this post in threaded view
|

[sonar-dev] About sonar.properties in the sonarqube distribution...

fge
Hello,

I had noticed that before but didn't pay anymore attention to it,
however, this is bugging me.

In sonar.conf, you can read:

---
# This file must contain only ISO 8859-1 characters.
---

Now, I suppose this means that Sonar is using a Properties instance
and uses the .load() method using an InputStream.

However, since Java 1.6, another method exists, which loads from a
Reader instead, therefore removing the need entirely for property
files to be hardcoded to ISO-8859-1 anymore.

Would sonar consider switching to UTF-8?

(as it is now this is of course not a problem since all characters
used in the properties file are in the ASCII printable range, for
which there is a 1 to 1 mapping between ISO-8859-1 and UTF-8 anyway,
and even CP1252; however, well, UTF-8 is pretty much the standard now,
so...)

Regards,
--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

Baptiste Mathus-4
Hi,

.properties files must be encoded by design in ISO-8859-1. The method you're talking about is just another facility to create an instance, but everything is still expected to be ISO-8859-1.

Maybe once JEP226 [1] is done, we'll be able to talk about it, hopefully. But not before.

Cheers

2015-03-26 13:00 GMT+01:00 Francis Galiegue <[hidden email]>:
Hello,

I had noticed that before but didn't pay anymore attention to it,
however, this is bugging me.

In sonar.conf, you can read:

---
# This file must contain only ISO 8859-1 characters.
---

Now, I suppose this means that Sonar is using a Properties instance
and uses the .load() method using an InputStream.

However, since Java 1.6, another method exists, which loads from a
Reader instead, therefore removing the need entirely for property
files to be hardcoded to ISO-8859-1 anymore.

Would sonar consider switching to UTF-8?

(as it is now this is of course not a problem since all characters
used in the properties file are in the ASCII printable range, for
which there is a 1 to 1 mapping between ISO-8859-1 and UTF-8 anyway,
and even CP1252; however, well, UTF-8 is pretty much the standard now,
so...)

Regards,
--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_emailnbsp;!
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

fge
Hello,

On Sun, Mar 29, 2015 at 8:08 AM, Baptiste Mathus <[hidden email]> wrote:
> Hi,
>
> .properties files must be encoded by design in ISO-8859-1. The method you're
> talking about is just another facility to create an instance, but everything
> is still expected to be ISO-8859-1.
>

Have you tried?

Because this is not true, or I don't understand what you mean by "by
design". As a proof, look at this project:
https://github.com/fge/msg-simple

I do use it with property files encoded in UTF-8.

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

Baptiste MATHUS-2
Standard .properties files are currently expected to be encoded in ISO-8859-1 to be loadable by the java.util.Properties class, and characters not representable in that encoding expected to be defined with unicode escape. Just read the class javadoc, wikipedia, the JEP above...

Now, sonar.conf isn't expected to be .properties file per se, granted. The SQ team could decide to say that file is expected to be UTF-8 encoded. 
Though I don't see much value spending time there.



2015-03-29 10:26 GMT+02:00 Francis Galiegue <[hidden email]>:
Hello,

On Sun, Mar 29, 2015 at 8:08 AM, Baptiste Mathus <[hidden email]> wrote:
> Hi,
>
> .properties files must be encoded by design in ISO-8859-1. The method you're
> talking about is just another facility to create an instance, but everything
> is still expected to be ISO-8859-1.
>

Have you tried?

Because this is not true, or I don't understand what you mean by "by
design". As a proof, look at this project:
https://github.com/fge/msg-simple

I do use it with property files encoded in UTF-8.

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

fge
On Sun, Mar 29, 2015 at 8:20 PM, Baptiste Mathus <[hidden email]> wrote:
> Standard .properties files are currently expected to be encoded in
> ISO-8859-1 to be loadable by the java.util.Properties class, and characters
> not representable in that encoding expected to be defined with unicode
> escape. Just read the class javadoc, wikipedia, the JEP above...
>

But Properties can .load(Reader) since Java 6. Therefore it means
property files are not limited to being encoded in ISO anymore!

> Now, sonar.conf isn't expected to be .properties file per se, granted. The
> SQ team could decide to say that file is expected to be UTF-8 encoded.
> Though I don't see much value spending time there.
>

Well, it's just a matter of changing a .load() call...

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

Simon Brandhof
@Baptiste I confirm this difference between Properties#load(Reader) and load(InputStream). I didn't know about that, even if I already used the first one when loading sonar.properties. So everything is ok, at least in version 4.5.4 (I didn't check earlier). I just removed the bad comment from header of sonar.properties.  
Thanks



Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

On 29 March 2015 at 20:29, Francis Galiegue <[hidden email]> wrote:
On Sun, Mar 29, 2015 at 8:20 PM, Baptiste Mathus <[hidden email]> wrote:
> Standard .properties files are currently expected to be encoded in
> ISO-8859-1 to be loadable by the java.util.Properties class, and characters
> not representable in that encoding expected to be defined with unicode
> escape. Just read the class javadoc, wikipedia, the JEP above...
>

But Properties can .load(Reader) since Java 6. Therefore it means
property files are not limited to being encoded in ISO anymore!

> Now, sonar.conf isn't expected to be .properties file per se, granted. The
> SQ team could decide to say that file is expected to be UTF-8 encoded.
> Though I don't see much value spending time there.
>

Well, it's just a matter of changing a .load() call...

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] About sonar.properties in the sonarqube distribution...

Baptiste MATHUS-2
@Simon then I think you should indeed add a comment in replacement saying that that .properties is expecting UTF-8 encoding, contrary to what most people expect of that file extension (and so that they configure their text editor accordingly when touching it). 
Even better, as I said above, would be IMO to not name it .properties at some point but sonar.conf or something to clarify the distance SQ is taking from standard encoding for that type of file.

Cheers

2015-03-30 23:27 GMT+02:00 Simon Brandhof <[hidden email]>:
@Baptiste I confirm this difference between Properties#load(Reader) and load(InputStream). I didn't know about that, even if I already used the first one when loading sonar.properties. So everything is ok, at least in version 4.5.4 (I didn't check earlier). I just removed the bad comment from header of sonar.properties.  
Thanks



Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

On 29 March 2015 at 20:29, Francis Galiegue <[hidden email]> wrote:
On Sun, Mar 29, 2015 at 8:20 PM, Baptiste Mathus <[hidden email]> wrote:
> Standard .properties files are currently expected to be encoded in
> ISO-8859-1 to be loadable by the java.util.Properties class, and characters
> not representable in that encoding expected to be defined with unicode
> escape. Just read the class javadoc, wikipedia, the JEP above...
>

But Properties can .load(Reader) since Java 6. Therefore it means
property files are not limited to being encoded in ISO anymore!

> Now, sonar.conf isn't expected to be .properties file per se, granted. The
> SQ team could decide to say that file is expected to be UTF-8 encoded.
> Though I don't see much value spending time there.
>

Well, it's just a matter of changing a .load() call...

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email






--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !