save and restore the current default locale, to avoid any side effects on other executions in the same JVM

This commit is contained in:
Simulant
2025-12-20 22:27:45 +01:00
parent 128fb42ccc
commit 421abfdc1f

View File

@@ -36,6 +36,9 @@ public class JSONObjectLocaleTest {
MyLocaleBean myLocaleBean = new MyLocaleBean();
// save and restore the current default locale, to avoid any side effects on other executions in the same JVM
Locale defaultLocale = Locale.getDefault();
try {
/**
* This is just the control case which happens when the locale.ROOT
* lowercasing behavior is the same as the current locale.
@@ -56,5 +59,8 @@ public class JSONObjectLocaleTest {
assertEquals("expected size 2, found: " +jsontr.length(), 2, jsontr.length());
assertEquals("expected jsontr[i] == beanI", "beanI", jsontr.getString("i"));
assertEquals("expected jsontr[id] == beanId", "beanId", jsontr.getString("id"));
} finally {
Locale.setDefault(defaultLocale);
}
}
}