-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Describe the bug
The ElementalNode classes wrap Jackson's nodes (such as ObjectNode or ArrayNode) while implementing the JsonValue interface from Elemental JSON API. However, these classes do not implement the specific Elemental interfaces (such as JsonObject or JsonArray).
JsonMigrationHelper/src/main/java/com/flowingcode/vaadin/jsonmigration/ElementalObjectNode.java
Line 34 in 6239275
| class ElementalObjectNode extends ObjectNode implements UnsupportedJsonValueImpl { |
The utility method convertToClientCallableResult uses a generic constraint
JsonMigrationHelper/src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper.java
Line 31 in 6239275
| <T extends JsonValue> T convertToClientCallableResult(T object); |
While the code compiles successfully, this results in a runtime failure whenever a client callable method attempts to cast the return value to a specific subtype.
Expected behavior
The result of convertToClientCallableResult must actually implement the expected subtype interface.
Minimal reproducible example
Consider a typical migration helper usage:
public JsonObject getJsonData() {
JsonObject result = ...
// The helper returns JsonObject, so it compiles.
// However, the JVM cannot cast the resulting object to JsonObject at runtime.
return JsonMigration.convertToClientCallableResult(result);
}Add-on Version
0.9.1
Vaadin Version
25.0.2
Additional information
To complicate things more, the specific Elemental interfaces cannot be implemented directly in the Java source code because of a fundamental conflict in method signatures between the two APIs.
- Elemental API: In the subtype interfaces mutation methods are designed to return void.
- Jackson API: The mutation methods in the node classes are designed to be fluent.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status