HADOOP-15817. Reuse Object Mapper in KMSJSONReader. Contributed by Jonathan Eagles.

This commit is contained in:
Yiqun Lin 2018-10-04 10:30:30 +08:00
parent 39b35036ba
commit 81f635f47f

View File

@ -38,6 +38,7 @@
@Consumes(MediaType.APPLICATION_JSON)
@InterfaceAudience.Private
public class KMSJSONReader implements MessageBodyReader<Object> {
private static final ObjectMapper MAPPER = new ObjectMapper();
@Override
public boolean isReadable(Class<?> type, Type genericType,
@ -51,7 +52,6 @@ public Object readFrom(Class<Object> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(entityStream, type);
return MAPPER.readValue(entityStream, type);
}
}