Skip to content

Commit

Permalink
Fix toUpperCase default locale warnings
Browse files Browse the repository at this point in the history
toUpperCase() will use the default locale if not instructed otherwise.
This can result in unexpected behavior on non-US devices.

Signed-off-by: Jorrit Jongma <[email protected]>
  • Loading branch information
cernekee authored and Chainfire committed Jul 31, 2013
1 parent 994c6c2 commit e7dacc4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libsuperuser/src/eu/chainfire/libsuperuser/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down Expand Up @@ -83,7 +84,7 @@ public static List<String> run(String shell, String[] commands, boolean wantSTDE
* @return Output of the commands, or null in case of an error
*/
public static List<String> run(String shell, String[] commands, String[] environment, boolean wantSTDERR) {
String shellUpper = shell.toUpperCase();
String shellUpper = shell.toUpperCase(Locale.ENGLISH);

if (Debug.sanityChecksEnabled()) {
// check if we're running in the main thread, and if so, crash if we're in debug mode,
Expand Down Expand Up @@ -161,7 +162,7 @@ public static List<String> run(String shell, String[] commands, String[] environ
res = null;
}

Debug.logCommand(String.format("[%s%%] END", shell.toUpperCase()));
Debug.logCommand(String.format("[%s%%] END", shell.toUpperCase(Locale.ENGLISH)));
return res;
}

Expand Down Expand Up @@ -882,7 +883,7 @@ private void runNextCommand(boolean notifyIdle) {
this.command = command;
startWatchdog();
for (String write : command.commands) {
Debug.logCommand(String.format("[%s+] %s", shell.toUpperCase(), write));
Debug.logCommand(String.format("[%s+] %s", shell.toUpperCase(Locale.ENGLISH), write));
STDIN.writeBytes(write + "\n");
}
STDIN.writeBytes("echo " + command.marker + " $?\n");
Expand Down Expand Up @@ -1007,7 +1008,7 @@ private void endCallback() {
* @return Opened successfully ?
*/
private synchronized boolean open() {
Debug.log(String.format("[%s%%] START", shell.toUpperCase()));
Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));

try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
Expand All @@ -1027,7 +1028,7 @@ private synchronized boolean open() {
}

STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase() + "-", process.getInputStream(), new OnLineListener() {
STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
Expand All @@ -1048,7 +1049,7 @@ public void onLine(String line) {
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase() + "*", process.getErrorStream(), new OnLineListener() {
STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
Expand Down Expand Up @@ -1131,7 +1132,7 @@ public void close() {
// this should really be re-thrown
}

Debug.log(String.format("[%s%%] END", shell.toUpperCase()));
Debug.log(String.format("[%s%%] END", shell.toUpperCase(Locale.ENGLISH)));
}

/**
Expand Down

0 comments on commit e7dacc4

Please sign in to comment.