From 1340617535cd3300929aa29fa2a8b12afc464e89 Mon Sep 17 00:00:00 2001 From: Haohui Mai Date: Tue, 9 Dec 2014 13:10:03 -0800 Subject: [PATCH] HADOOP-11378. Fix new findbugs warnings in hadoop-kms. Contributed by Li Lu. --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index e6b44e9f27..40aab85646 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -550,6 +550,8 @@ Release 2.7.0 - UNRELEASED HADOOP-11379. Fix new findbugs warnings in hadoop-auth*. (Li Lu via wheat9) + HADOOP-11378. Fix new findbugs warnings in hadoop-kms. (Li Lu via wheat9) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java index 3674e7a87a..31fac9f7b2 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java @@ -32,6 +32,7 @@ import java.io.Writer; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.nio.charset.Charset; import java.util.List; import java.util.Map; @@ -62,7 +63,8 @@ public void writeTo(Object obj, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { - Writer writer = new OutputStreamWriter(outputStream); + Writer writer = new OutputStreamWriter(outputStream, Charset + .forName("UTF-8")); ObjectMapper jsonMapper = new ObjectMapper(); jsonMapper.writerWithDefaultPrettyPrinter().writeValue(writer, obj); }