Skip to content

Commit 95a443f

Browse files
authored
fix: add reflection hints for Dependency class (#22872)
In previous Flow versions, Dependency class had a toJson method that created an elemental JsonObject to be sent to the client as JSON. However, the method has been removed and replaced by Jackson serialization. This causes wrong JSON serialization in native executables because reflection is required, but metadata is not stored for the Dependency class. This change adds the missing reflection hint for the Dependency class. It also replaces a useless JSON to string to JSON conversion. Fixes #22870
1 parent 34e516b commit 95a443f

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

flow-server/src/main/java/com/vaadin/flow/server/communication/UidlWriter.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
36-
import tools.jackson.core.JacksonException;
3736
import tools.jackson.databind.JsonNode;
3837
import tools.jackson.databind.node.ArrayNode;
3938
import tools.jackson.databind.node.ObjectNode;
@@ -221,15 +220,8 @@ private static void populateDependencies(ObjectNode response,
221220

222221
if (!pendingSendToClient.isEmpty()) {
223222
groupDependenciesByLoadMode(pendingSendToClient, context)
224-
.forEach((loadMode, dependencies) -> {
225-
try {
226-
response.set(loadMode.name(),
227-
JacksonUtils.getMapper()
228-
.readTree(dependencies.toString()));
229-
} catch (JacksonException e) {
230-
throw new RuntimeException(e);
231-
}
232-
});
223+
.forEach((loadMode, dependencies) -> response
224+
.set(loadMode.name(), dependencies));
233225
}
234226
dependencyList.clearPendingSendToClient();
235227
}

vaadin-spring/src/main/java/com/vaadin/flow/spring/springnative/VaadinHintsRegistrar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.vaadin.flow.router.internal.DefaultErrorHandler;
3838
import com.vaadin.flow.server.menu.AvailableViewInfo;
3939
import com.vaadin.flow.server.menu.RouteParamType;
40+
import com.vaadin.flow.shared.ui.Dependency;
4041

4142
/**
4243
* Registers runtime hints for Spring 3 native support.
@@ -134,7 +135,7 @@ private String[] getClasses() {
134135
AvailableViewInfo.class.getName(),
135136
AvailableViewInfo.DetailDeserializer.class.getName(),
136137
AvailableViewInfo.DetailSerializer.class.getName(),
137-
RouteParamType.class.getName() };
138+
RouteParamType.class.getName(), Dependency.class.getName() };
138139
}
139140

140141
}

0 commit comments

Comments
 (0)