From d444541947c3c44a2afe990ea0556a7c0c14106c Mon Sep 17 00:00:00 2001 From: Gabor Bernat Date: Tue, 15 Mar 2016 09:48:47 +0100 Subject: [PATCH] fix issue #38 --- .../java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java | 7 +++---- src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java | 3 +-- .../com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java | 3 +-- src/main/java/com/googlecode/jsonrpc4j/ReadContext.java | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java index a0cd77d2..7f5e9076 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.type.TypeFactory; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -65,11 +64,11 @@ public class JsonRpcBasicServer { public static final String VERSION = "2.0"; public static final int CODE_OK = 0; - private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(); - private static final ErrorResolver DEFAULT_ERROR_RESOLVER = new MultipleErrorResolver(AnnotationsErrorResolver.INSTANCE, DefaultErrorResolver.INSTANCE); public static final String WEB_PARAM_ANNOTATION_CLASS_LOADER = "javax.jws.WebParam"; public static final String NAME = "name"; public static final String NULL = "null"; + private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(); + private static final ErrorResolver DEFAULT_ERROR_RESOLVER = new MultipleErrorResolver(AnnotationsErrorResolver.INSTANCE, DefaultErrorResolver.INSTANCE); private static Class WEB_PARAM_ANNOTATION_CLASS; private static Method WEB_PARAM_NAME_METHOD; @@ -413,7 +412,7 @@ private Object[] convertJsonToParameters(Method m, List params) throws for (int i = 0; i < parameterTypes.length; i++) { JsonParser paramJsonParser = mapper.treeAsTokens(params.get(i)); - JavaType paramJavaType = TypeFactory.defaultInstance().constructType(parameterTypes[i]); + JavaType paramJavaType = mapper.getTypeFactory().constructType(parameterTypes[i]); convertedParams[i] = mapper.readValue(paramJsonParser, paramJavaType); } return convertedParams; diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java index be31bee1..26d82396 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.type.TypeFactory; import java.io.IOException; import java.io.InputStream; @@ -265,7 +264,7 @@ private boolean isReturnTypeInvalid(Type returnType) { private Object constructResponseObject(Type returnType, ObjectNode jsonObject) throws IOException { JsonParser returnJsonParser = mapper.treeAsTokens(jsonObject.get(RESULT)); - JavaType returnJavaType = TypeFactory.defaultInstance().constructType(returnType); + JavaType returnJavaType = mapper.getTypeFactory().constructType(returnType); return mapper.readValue(returnJsonParser, returnJavaType); } diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java index 917927c1..0e8141d5 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java @@ -46,7 +46,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.type.TypeFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -372,7 +371,7 @@ private T readResponse(Type returnType, InputStream ips) throws Throwable { if (jsonObject.has(RESULT) && !jsonObject.get(RESULT).isNull() && jsonObject.get(RESULT) != null) { JsonParser returnJsonParser = mapper.treeAsTokens(jsonObject.get(RESULT)); - JavaType returnJavaType = TypeFactory.defaultInstance().constructType(returnType); + JavaType returnJavaType = mapper.getTypeFactory().constructType(returnType); return mapper.readValue(returnJsonParser, returnJavaType); } diff --git a/src/main/java/com/googlecode/jsonrpc4j/ReadContext.java b/src/main/java/com/googlecode/jsonrpc4j/ReadContext.java index 16b889a3..358a1200 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/ReadContext.java +++ b/src/main/java/com/googlecode/jsonrpc4j/ReadContext.java @@ -21,8 +21,7 @@ public synchronized static ReadContext getReadContext(InputStream input, ObjectM return new ReadContext(input, mapper); } - public JsonNode nextValue() - throws IOException { + public JsonNode nextValue() throws IOException { return mapper.readValue(input, JsonNode.class); }