Skip to content

Commit 8966753

Browse files
Emergency fix for Dev JsonPRC calls using JsonObject
Signed-off-by: Phillip Kruger <[email protected]>
1 parent 791693a commit 8966753

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

extensions/devui/runtime/src/main/java/io/quarkus/devui/runtime/jsonrpc/JsonRpcRequest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
import java.util.Map;
44

5+
import io.quarkus.devui.runtime.jsonrpc.json.JsonMapper;
6+
57
public final class JsonRpcRequest {
68
private int id;
79
private String jsonrpc = JsonRpcKeys.VERSION;
810
private String method;
9-
private Map params;
11+
private Map<String, Object> params;
12+
private final JsonMapper jsonMapper;
13+
14+
public JsonRpcRequest(JsonMapper jsonMapper) {
15+
this.jsonMapper = jsonMapper;
16+
}
1017

1118
public int getId() {
1219
return id;
@@ -36,7 +43,7 @@ public Map getParams() {
3643
return params;
3744
}
3845

39-
public void setParams(Map params) {
46+
public void setParams(Map<String, Object> params) {
4047
this.params = params;
4148
}
4249

@@ -50,7 +57,7 @@ public boolean hasParam(String key) {
5057

5158
public <T> T getParam(String key, Class<T> paramType) {
5259
if (hasParam(key)) {
53-
return (T) this.params.get(key);
60+
return jsonMapper.fromValue(params.get(key), paramType);
5461
}
5562
return null;
5663
}

extensions/devui/runtime/src/main/java/io/quarkus/devui/runtime/jsonrpc/JsonRpcRequestCreator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private JsonRpcRequest remap(JsonRpcRequest jsonRpcRequest) {
5151
String mappedName = (String) params.remove("name");
5252
Map mappedParams = (Map) params.remove("arguments");
5353

54-
JsonRpcRequest mapped = new JsonRpcRequest();
54+
JsonRpcRequest mapped = new JsonRpcRequest(this.jsonMapper);
5555
mapped.setId(jsonRpcRequest.getId());
5656
mapped.setJsonrpc(jsonRpcRequest.getJsonrpc());
5757
mapped.setMethod(mappedName);
@@ -67,7 +67,7 @@ public String toJson(JsonRpcRequest jsonRpcRequest) {
6767
}
6868

6969
private JsonRpcRequest createWithFilter(JsonObject jsonObject, String... filter) {
70-
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest();
70+
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(this.jsonMapper);
7171
if (jsonObject.containsKey(ID)) {
7272
jsonRpcRequest.setId(jsonObject.getInteger(ID));
7373
}
@@ -76,7 +76,7 @@ private JsonRpcRequest createWithFilter(JsonObject jsonObject, String... filter)
7676
}
7777
jsonRpcRequest.setMethod(jsonObject.getString(METHOD));
7878
if (jsonObject.containsKey(PARAMS)) {
79-
Map map = jsonObject.getJsonObject(PARAMS).getMap();
79+
Map<String, Object> map = jsonObject.getJsonObject(PARAMS).getMap();
8080
if (filter != null) {
8181
for (String p : filter) {
8282
map.remove(p);

0 commit comments

Comments
 (0)