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
diff --git a/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java b/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java index b6a35ee..8b41b80 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java +++ b/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java
@@ -30,6 +30,7 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import javax.annotation.Nullable; @@ -98,7 +99,7 @@ DEREFERENCE; public static SymlinkBehavior parse(String value) throws IllegalArgumentException { - return valueOf(value.toUpperCase()); + return valueOf(value.toUpperCase(Locale.ENGLISH)); } @Override