Skip to content

Commit

Permalink
Merge pull request #260 from anysoft/master
Browse files Browse the repository at this point in the history
fix #251
  • Loading branch information
briandilley authored Jan 27, 2021
2 parents a8500dc + 73e9d71 commit 4d32e9d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/com/googlecode/jsonrpc4j/JsonRpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private boolean isIdValueNotCorrect(String id, ObjectNode jsonObject) {
}

protected boolean hasError(ObjectNode jsonObject) {
return jsonObject.has(ERROR) && jsonObject.get(ERROR) != null && !jsonObject.get(ERROR).isNull();
return jsonObject.has(ERROR) && jsonObject.get(ERROR) != null && !jsonObject.get(ERROR).isNull() && !(jsonObject.get(ERROR).isInt() && jsonObject.intValue()==0) ;
}

/**
Expand All @@ -343,6 +343,7 @@ private ObjectNode internalCreateRequest(String methodName, Object arguments, St
addParameters(arguments, request);
addAdditionalHeaders(request);
notifyBeforeRequestListener(request);
addNoneArguments(request);
return request;
}

Expand Down Expand Up @@ -423,6 +424,13 @@ private boolean isCollectionArguments(Object arguments) {
return arguments != null && Collection.class.isInstance(arguments);
}

private void addNoneArguments(ObjectNode request){
if (!request.has(PARAMS)){
//for none params add an empty array
request.set(PARAMS,mapper.valueToTree(new String[0]));
}
}

private void addCollectionArguments(Object arguments, ObjectNode request) {
Collection<?> args = Collection.class.cast(arguments);
if (!args.isEmpty()) {
Expand Down

0 comments on commit 4d32e9d

Please sign in to comment.