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:32:56 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 b170de8be -> 2b6d8c1e2


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/2b6d8c1e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2b6d8c1e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2b6d8c1e

Branch: refs/heads/branch-3.0
Commit: 2b6d8c1e295f9f0304271b6e1658b28d5ca4c3bf
Parents: b170de8
Author: Jonathan Eagles <jeagles@yahoo-inc.com>
Authored: Wed Oct 10 10:32:43 2018 -0500
Committer: Jonathan Eagles <jeagles@yahoo-inc.com>
Committed: Wed Oct 10 10:32:43 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/2b6d8c1e/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 f826572..4f002aa 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
@@ -18,7 +18,7 @@
 package org.apache.hadoop.crypto.key.kms.server;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-
+import com.fasterxml.jackson.databind.ObjectWriter;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.http.JettyUtils;
 
@@ -46,6 +46,8 @@ import java.util.Map;
 @Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
 @InterfaceAudience.Private
 public class KMSJSONWriter implements MessageBodyWriter<Object> {
+  private static final ObjectWriter WRITER =
+      new ObjectMapper().writerWithDefaultPrettyPrinter();
 
   @Override
   public boolean isWriteable(Class<?> aClass, Type type,
@@ -67,8 +69,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