From 7b88a57c379fe6eba7d685362e0bc756fdeff700 Mon Sep 17 00:00:00 2001 From: Yiqun Lin Date: Thu, 4 Oct 2018 10:30:30 +0800 Subject: [PATCH] HADOOP-15817. Reuse Object Mapper in KMSJSONReader. Contributed by Jonathan Eagles. (cherry picked from commit 81f635f47f0737eb551bef1aa55afdf7b268253d) --- .../apache/hadoop/crypto/key/kms/server/KMSJSONReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONReader.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONReader.java index d3e0064db82..a59e94c2904 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONReader.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSJSONReader.java @@ -36,6 +36,7 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) @InterfaceAudience.Private public class KMSJSONReader implements MessageBodyReader { + private static final ObjectMapper MAPPER = new ObjectMapper(); @Override public boolean isReadable(Class type, Type genericType, @@ -48,7 +49,6 @@ public class KMSJSONReader implements MessageBodyReader { Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(entityStream, type); + return MAPPER.readValue(entityStream, type); } }