log-synth icon indicating copy to clipboard operation
log-synth copied to clipboard

"Locale" issues when compiling log-synth

Open assis opened this issue 5 years ago • 3 comments

Hi, there! While compiling log-synth, maven reported failures when performing tests, which prevented it from completing the building process. For example, when testing ZipSampler, an error was produced when trying to convert a string like "99,9999" to double by using Java's Double.parseDouble(). I realized it was happening because of "locale issues". I am in Brazil, using Xubuntu 18.04. In my terminals, the default locale is "pt_BR.UTF-8". Here, a comma (",") is used as decimal separator (instead of "."). In ZipSampler, for example, an Exception was being raised because of line 262:

return accept(Double.parseDouble(latitude), Double.parseDouble(longitude));

Lines 256 and 257 are as follows:

String longitude = location.get("longitude").asText(); String latitude = location.get("latitude").asText();

Due to my locale, asText() method produces floating point strings using "," as decimal separator. In order to get the code compiled, I executed

export LC_ALL=en_US.utf8 export LANG=en_US.utf8 (just in case)

on a terminal, ran

mvn clean mvn package

and compilation was successfully finished.

If there is an easier way to solve this issue, please let me know. If not, I'd suggest to set locale to "en_US-UTF-8" on testing classes.

Also, if anything more than "mvn package" is required for compilation, please let me know. I could not find compilation instructions on log-synth documentation.

Thanks!

assis avatar Aug 24 '19 03:08 assis

Thanks for the comments.

You are correct that I didn't think about LOCALE when I was writing those tests (American bias, of course).

Do you have some suggestions about how and where to set the locale to make this safe for the rest of the world?

And yes, mvn package is all you need. That will create a standalone executable in the target directory.

On Fri, Aug 23, 2019 at 8:48 PM Alexandre A. B. Lima < [email protected]> wrote:

Hi, there! While compiling log-synth, maven reported failures when performing tests, which prevented it from completing the building process. For example, when testing ZipSampler, an error was produced when trying to convert a string like "99,9999" to double by using Java's Double.parseDouble(). I realized it was happening because of "locale issues". I am in Brazil, using Xubuntu 18.04. In my terminals, the default locale is "pt_BR.UTF-8". Here, a comma (",") is used as decimal separator (instead of "."). In ZipSampler, for example, an Exception was being raised because of line 262:

return accept(Double.parseDouble(latitude), Double.parseDouble(longitude));

Lines 256 and 257 are as follows:

String longitude = location.get("longitude").asText(); String latitude = location.get("latitude").asText();

Due to my locale, asText() method produces floating point strings using "," as decimal separator. In order to get the code compiled, I executed

export LC_ALL=en_US.utf8 export LANG=en_US.utf8 (just in case)

on a terminal, ran

mvn clean mvn package

and compilation was successfully finished.

If there is an easier way to solve this issue, please let me know. If not, I'd suggest to set locale to "en_US-UTF-8" on testing classes.

Also, if anything more than "mvn package" is required for compilation, please let me know. I could not find compilation instructions on log-synth documentation.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tdunning/log-synth/issues/35?email_source=notifications&email_token=AAB5E6UTT4I3J7H24PPIVHTQGCVQJA5CNFSM4IPFBXR2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHFCJNA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB5E6RPUFGIVS5W42G75STQGCVQJANCNFSM4IPFBXRQ .

tdunning avatar Aug 24 '19 05:08 tdunning

You're welcome! Thank you for sharing log-synth!

I never used Jackson. I believe it is "locale-aware". Maybe, this could help: it seems the ObjectMapper class has a method called setLocale() that may be useful:

https://www.tutorialspoint.com/jackson/jackson_quick_guide.htm

I didn't find any way to set it globally, but, as I said, I never used this suite before. I wish I could help more. If you find a solution, please let me know.

Best Regards!

assis avatar Aug 25 '19 04:08 assis

Thank you again.

On Sat, Aug 24, 2019 at 9:09 PM Alexandre A. B. Lima < [email protected]> wrote:

You're welcome! Thank you for sharing log-synth!

I never used Jackson. I believe it is "locale-aware". Maybe, this could help: it seems the ObjectMapper class has a method called setLocale() that may be useful:

https://www.tutorialspoint.com/jackson/jackson_quick_guide.htm

I didn't find any way to set it globally, but, as I said, I never used this suite before. I wish I could help more. If you find a solution, please let me know.

Best Regards!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tdunning/log-synth/issues/35?email_source=notifications&email_token=AAB5E6SUCLHZO4425WK7CJLQGIAWVA5CNFSM4IPFBXR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5CL4OQ#issuecomment-524598842, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB5E6UJAGIU3JCPWUGL6NLQGIAWVANCNFSM4IPFBXRQ .

tdunning avatar Aug 25 '19 05:08 tdunning