JSON-java icon indicating copy to clipboard operation
JSON-java copied to clipboard

Test does not restore default locale

Open eleumik opened this issue 2 months ago • 2 comments

https://github.com/stleary/JSON-java/blob/master/src/test/java/org/json/junit/JSONObjectLocaleTest.java

This test changes the default JVM locale and doesn’t restore it. Since Maven runs tests in the same JVM unless forking is enabled, this can influence other tests.

Yesterday i checked all the occurrences of Locale.setDefault in my projects and I found also this. It causes subtle problems when running / mvn packaging many modules together.

It is of course very low priority and relevant only if one runs many builds in sequence, more for other projects than for this one

Thanks Michele

PS. today is TimeZone.setDefault day, yes I am having fun...

eleumik avatar Nov 19 '25 11:11 eleumik

@eleumik Sorry for not responding sooner, Gmail was sending my GItHub emails to spam. Good catch with the locale problem, and sorry it caused a problem in your workflow. If you have a fix, feel free to submit it, otherwise I will try to fix it when time permits - maybe after the new year.

stleary avatar Dec 11 '25 03:12 stleary

no problem at all, thanks, I just find it browsing my projects; fix is to store initial default locale and restore it in a finally block, i will try to do but little time

eleumik avatar Dec 14 '25 06:12 eleumik