Skip to content
Permalink
Browse files
[FIXED JENKINS-11874] if can't obtain computer's charset, use UTF-8
  • Loading branch information
deluan committed Dec 12, 2011
1 parent 9bc221b commit 9cfe7a99c669b98cf628d604d724ff96a36e1d13
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/main/java/com/deluan/jenkins/plugins/rtc/JazzClient.java
@@ -13,6 +13,7 @@
import org.kohsuke.stapler.framework.io.WriterOutputStream;

import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -170,7 +171,7 @@ private ByteArrayOutputStream popen(ArgumentListBuilder args)
// scm produces text in the platform default encoding, so we need to convert it back to UTF-8
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WriterOutputStream o = new WriterOutputStream(new OutputStreamWriter(baos, "UTF-8"),
Computer.currentComputer().getDefaultCharset());
getDefaultCharset());

PrintStream output = listener.getLogger();
ForkOutputStream fos = new ForkOutputStream(o, output);
@@ -182,4 +183,13 @@ private ByteArrayOutputStream popen(ArgumentListBuilder args)
throw new AbortException();
}
}

private Charset getDefaultCharset() {
// First check if we can get currentComputer. See issue JENKINS-11874
if (Computer.currentComputer() != null) {
return Computer.currentComputer().getDefaultCharset();
} else {
return Charset.forName("UTF-8");
}
}
}

0 comments on commit 9cfe7a9

Please sign in to comment.