Hi there, it seems that as of Gradle 2.1 (introduced I guess by this defect fixed GRADLE-3142) ‘user.country.format’ is no longer being set for forked tests, which is then breaking things that rely on that format (yes the tests shouldn’t be doing that)
I think that because the fix for that issue started including some locale params, the JVM is no longer adding the extra ones like ‘user.country.format’.
I think a fix would be to just add in ‘user.country.format’ (and user.language.format, user.language.display, user.country.format) to be passed along if they are provided as well.
My temp fix has been to just add ‘user.country.format’ to the list of system properties for tests in my build.gradle.
It’s not entirely clear what’s going on here. Would you be able to provide a build and reproducible instructions?
Gradle has never “managed” the user.language.format properties, so nothing should have actually changed here. it seems like there’s some inherent JVM behaviour regarding deriving those runtime values from some of the properties we newly managed.
If you can provide some instructions for reproducing the problem, it should be pretty straightforward to fix.
What I think is happening is that when we pass ‘user.country’ as a system property, the JVM stops automatically setting user.country.format.
Take this example …
import java.util.Locale;
public class Test {
public static void main(String... args) {
System.out.println(System.getProperty("user.country"));
System.out.println(System.getProperty("user.country.format"));
System.out.println(Locale.getDefault());
System.out.println(Locale.getDefault(Locale.Category.FORMAT));
}
}
If I run it as java Test
The output is (I’m in New Zealand)
US
NZ
en_US
en_NZ
However as java -Duser.country=US Test
The output is
US
null
en_US
en_US
So since GRADLE-3142 now means that user.country is set for the forked Test task, the forked task isn’t getting user.country.format set.
So yeah I think the fix is to just pass down user.country.format if it has been set … and I listed those other 3 properties because I imagine that they behave in the same way.