hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeag...@apache.org
Subject hadoop git commit: HADOOP-15835. Reuse Object Mapper in KMSJSONWriter (jeagles)
Date Wed, 10 Oct 2018 15:37:27 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.9 e75191a62 -> be06504a1


HADOOP-15835. Reuse Object Mapper in KMSJSONWriter (jeagles)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/be06504a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/be06504a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/be06504a

Branch: refs/heads/branch-2.9
Commit: be06504a125d0f8ca222047ebd2dfd414bad3427
Parents: e75191a
Author: Jonathan Eagles <jeagles@yahoo-inc.com>
Authored: Wed Oct 10 10:37:20 2018 -0500
Committer: Jonathan Eagles <jeagles@yahoo-inc.com>
Committed: Wed Oct 10 10:37:20 2018 -0500

----------------------------------------------------------------------
 .../apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/be06504a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONWriter.java
----------------------------------------------------------------------
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 31fac9f..2d154b3 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
@@ -19,7 +19,7 @@ package org.apache.hadoop.crypto.key.kms.server;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.codehaus.jackson.map.ObjectMapper;
-
+import org.codehaus.jackson.map.ObjectWriter;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
@@ -44,6 +44,8 @@ import java.util.Map;
 @Produces(MediaType.APPLICATION_JSON)
 @InterfaceAudience.Private
 public class KMSJSONWriter implements MessageBodyWriter<Object> {
+  private static final ObjectWriter WRITER =
+      new ObjectMapper().writerWithDefaultPrettyPrinter();
 
   @Override
   public boolean isWriteable(Class<?> aClass, Type type,
@@ -65,8 +67,7 @@ public class KMSJSONWriter implements MessageBodyWriter<Object> {
       OutputStream outputStream) throws IOException, WebApplicationException {
     Writer writer = new OutputStreamWriter(outputStream, Charset
         .forName("UTF-8"));
-    ObjectMapper jsonMapper = new ObjectMapper();
-    jsonMapper.writerWithDefaultPrettyPrinter().writeValue(writer, obj);
+    WRITER.writeValue(writer, obj);
   }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message