Skip to content

Commit

Permalink
Polish JSON RPC support
Browse files Browse the repository at this point in the history
References #378

(cherry picked from commit d79a8b0)
  • Loading branch information
acogoluegnes committed Aug 16, 2018
1 parent 06c5152 commit 6fecb1c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/rabbitmq/tools/json/JSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/**
* Will be removed in 6.0
*
* @deprecated Use a third-party JSON library, e.g. Jackson or GJSON
* @deprecated Use a third-party JSON library, e.g. Jackson or Gson
*/
public class JSONReader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* Will be removed in 6.0
*
* @deprecated Use a third-party JSON library, e.g. Jackson or GJSON
* @deprecated Use a third-party JSON library, e.g. Jackson or Gson
*/
public interface JSONSerializable {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rabbitmq/tools/json/JSONWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

/**
* Will be removed in 6.0
* @deprecated Use a third-party JSON library, e.g. Jackson or GJSON
* @deprecated Use a third-party JSON library, e.g. Jackson or Gson
*/
public class JSONWriter {
private boolean indentMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class DefaultJsonRpcMapper implements JsonRpcMapper {

@Override
public JsonRpcRequest parse(String requestBody, ServiceDescription description) {
@SuppressWarnings("unchecked")
Map<String, Object> request = (Map<String, Object>) new JSONReader().read(requestBody);
return new JsonRpcRequest(
request.get("id"), request.get("version").toString(), request.get("method").toString(),
Expand All @@ -47,6 +48,7 @@ public JsonRpcRequest parse(String requestBody, ServiceDescription description)

@Override
public JsonRpcResponse parse(String responseBody, Class<?> expectedType) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) (new JSONReader().read(responseBody));
Map<String, Object> error;
JsonRpcException exception = null;
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/com/rabbitmq/client/JacksonJsonRpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public void rpc() {
Date returnedDate = service.procedureDateDate(date);
assertEquals(date.getTime(), returnedDate.getTime());

try {
service.procedureException();
fail("Remote procedure throwing exception, an exception should have been thrown");
} catch (UndeclaredThrowableException e) {
assertTrue(e.getCause() instanceof JsonRpcException);
}

Pojo pojo = new Pojo();
pojo.setStringProperty("hello");
assertEquals("hello", service.procedurePojoToString(pojo));
Expand Down

0 comments on commit 6fecb1c

Please sign in to comment.