This is an automated email from the ASF dual-hosted git repository. randgalt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/curator.git
The following commit(s) were added to refs/heads/master by this push: new 9129a76 CURATOR-547 change JAX-RS reader/writer to reuse Jackson ObjectMapper; also Jackson 2.9.8 -> 2.9.10 9129a76 is described below commit 9129a768b0ad81e22f0bb7df32ff6039b76303de Author: Tatu Saloranta <tatu.salora...@iki.fi> AuthorDate: Thu Oct 10 22:23:56 2019 -0700 CURATOR-547 change JAX-RS reader/writer to reuse Jackson ObjectMapper; also Jackson 2.9.8 -> 2.9.10 --- .../x/discovery/server/entity/JsonServiceInstanceMarshaller.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java index 1b3fd96..b67c8b5 100644 --- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java +++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java @@ -48,6 +48,8 @@ import java.lang.reflect.Type; @Produces(MediaType.APPLICATION_JSON) public class JsonServiceInstanceMarshaller<T> implements MessageBodyReader<ServiceInstance<T>>, MessageBodyWriter<ServiceInstance<T>> { + private final static ObjectMapper mapper = new ObjectMapper(); + private final DiscoveryContext<T> context; public JsonServiceInstanceMarshaller(DiscoveryContext<T> context) @@ -140,8 +142,7 @@ public class JsonServiceInstanceMarshaller<T> implements MessageBodyReader<Servi { try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.reader().readTree(entityStream); + JsonNode node = mapper.readTree(entityStream); return readInstance(node, context); } catch ( Exception e ) @@ -154,8 +155,7 @@ public class JsonServiceInstanceMarshaller<T> implements MessageBodyReader<Servi @Override public void writeTo(ServiceInstance<T> serviceInstance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { - ObjectMapper mapper = new ObjectMapper(); ObjectNode node = writeInstance(mapper, serviceInstance, context); - mapper.writer().writeValue(entityStream, node); + mapper.writeValue(entityStream, node); } }