Skip to content

Commit 8e26263

Browse files
committed
Make DefaultCharset an error
FormatDiff decoded what a failed git command printed to stdout and stderr in the platform's charset, while the output of one that succeeds, three lines further down, is read as UTF-8. Both are UTF-8 now.
1 parent 7a2bac9 commit 8e26263

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎buildSrc/src/main/groovy/open-java-format.error-prone-conventions.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tasks.withType(JavaCompile).configureEach {
2727
}
2828
error('CanonicalAnnotationSyntax')
2929
error('CollectorMutability')
30+
error('DefaultCharset')
3031
error('DirectReturn')
3132
error('EffectivelyPrivate')
3233
error('FormatStringConcatenation')

‎gradle-open-java-format/src/main/java/com/palantir/javaformat/gradle/FormatDiff.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ private static String gitCommand(Path dir, String... args) throws IOException, I
135135
Preconditions.checkState(process.waitFor(30, TimeUnit.SECONDS), "git diff took too long to terminate");
136136
if (process.exitValue() != 0) {
137137
throw new RuntimeException("Expected return code of 0 but got " + process.exitValue()
138-
+ "\n stdout: " + new String(process.getInputStream().readAllBytes())
139-
+ "\n stderr: " + new String(process.getErrorStream().readAllBytes()));
138+
+ "\n stdout: " + new String(process.getInputStream().readAllBytes(), UTF_8)
139+
+ "\n stderr: " + new String(process.getErrorStream().readAllBytes(), UTF_8));
140140
}
141141
ByteArrayOutputStream baos = new ByteArrayOutputStream();
142142
process.getInputStream().transferTo(baos);

0 commit comments

Comments
 (0)