aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner/java
diff options
context:
space:
mode:
authorGravatar Jingwen Chen <jingwen@google.com>2018-05-11 08:56:06 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-11 08:57:16 -0700
commit91b867f6b1b5c417172efe1fa278282d14500922 (patch)
tree01bdfc404a15169ace91521e9866bbdce422b737 /src/java_tools/junitrunner/java
parenta8ddd36c3a68d9c58357399f349fd70a14d79d92 (diff)
Set Locale to English when uppercasing strings to match Enums
Fixes https://github.com/bazelbuild/bazel/issues/5157 If a user's default system locale is not `en`, `en_US` or `en_UK`, there may be a chance that `String#toUpperCase` will result in a string that does not exist in the Enum declaration. This is the case in #5157. To fix this, it's either 1) setting the Locale in the individual `toUpperCase` calls or 2) set Locale to English by default from `Bazel.java`. I chose the first because it seemed less intrusive, but I'm open to suggestions. Closes #5184. PiperOrigin-RevId: 196261078
Diffstat (limited to 'src/java_tools/junitrunner/java')
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/ShardingFilters.java10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/ShardingFilters.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/ShardingFilters.java
index 2a5b79cae4..a92de41f17 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/ShardingFilters.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/ShardingFilters.java
@@ -15,13 +15,11 @@
package com.google.testing.junit.runner.sharding;
import com.google.testing.junit.runner.sharding.api.ShardingFilterFactory;
-
-import org.junit.runner.Description;
-import org.junit.runner.manipulation.Filter;
-
import java.util.Collection;
-
+import java.util.Locale;
import javax.inject.Inject;
+import org.junit.runner.Description;
+import org.junit.runner.manipulation.Filter;
/**
* A factory for test sharding filters.
@@ -97,7 +95,7 @@ public class ShardingFilters {
}
ShardingFilterFactory shardingFilterFactory;
try {
- shardingFilterFactory = ShardingStrategy.valueOf(strategy.toUpperCase());
+ shardingFilterFactory = ShardingStrategy.valueOf(strategy.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();