From 81f635f47f0737eb551bef1aa55afdf7b268253d 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. --- .../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 f6f670be0a..af781f5277 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 @@ -38,6 +38,7 @@ @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, @@ -51,7 +52,6 @@ public Object readFrom(Class type, Type genericType, 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); } }