Repository navigation
fix(vaadin-spring): read vaadin.* properties in native images - #26039
Conversation
The list of properties copied from application.properties is built from the fields of InitParameters with reflection. Without a runtime hint the native image returned no fields, so all vaadin.* properties were ignored.
Type of change
How to test
|
Flow keeps only lookup initializers with a public no-arg constructor visible to getConstructors(). In a native image the constructor was not registered, so Flow silently used the default LookupInitializer, which ignores Spring beans such as the configuration factory that reads vaadin.* properties.
Without the two native hints, reflection quietly returns empty, so the servlet blanks the property list and falls back to the default lookupflowchart LR
subgraph Before
direction TB
B1["VaadinHintsRegistrar.registerHints() (no hints)"]
B2["InitParameters.class.getDeclaredFields() returns []"]
B3["SpringServlet.PROPERTY_NAMES = [] (vaadin.* ignored)"]
B4["ReflectTools.isInstantiableService(SpringLookupInitializer) returns false"]
B5["LookupServletContainerInitializer falls back to LookupInitializer"]
B1 -->|"leaves reflection metadata stripped"| B2
B2 -->|"empty field list"| B3
B1 -->|"leaves reflection metadata stripped"| B4
B4 -->|"excludes class from services"| B5
end
subgraph After
direction TB
A1["VaadinHintsRegistrar registers InitParameters fields and SpringLookupInitializer ctor"]:::changed
A2["InitParameters.class.getDeclaredFields() returns vaadin.* names"]
A3["SpringServlet.PROPERTY_NAMES populated"]
A4["ReflectTools.isInstantiableService(SpringLookupInitializer) returns true"]
A5["LookupServletContainerInitializer selects SpringLookupInitializer"]:::changed
A1 -->|"keeps reflection metadata"| A2
A2 -->|"vaadin.* names collected"| A3
A1 -->|"keeps reflection metadata"| A4
A4 -->|"includes class in services"| A5
end
Before ~~~ After
classDef changed stroke:#c9a227,stroke-width:3px
Per the pull request description, two reflection calls had no native-image hint: Diagram Bot draws the mechanism this pull request touches; it does not review the change. Verify it against the diff.
|
|
|
Documentation Bot: No documentation needed for this change. This PR is an Nothing was opened in vaadin/docs. If you disagree, the change has to be documented by hand there.
|



behavior deviation · vaadin-spring · Spring Boot apps built as a
GraalVM native image
In a Spring Boot native image, Flow ignored every
vaadin.*property inapplication.properties. For examplevaadin.productionMode=truehad noeffect, so an app without a
flow-build-info.jsontoken file started indevelopment mode and failed with "'vaadin-dev-server' not found". There is
no workaround other than servlet init parameters set in code.
Risks:
vaadin.*properties, as JVMapps always did. A wrong value in the file that nobody noticed is now used.
that Spring apps provide as beans (not only the configuration factory) are
used as on the JVM. Before, the default implementations were used silently.
threading, performance or migration impact.
Context. Two reflection calls had no native hint. The property names
come from the constants in
InitParameters, and the list was empty. Flowkeeps a lookup initializer only if reflection finds its public no-arg
constructor, so it dropped
SpringLookupInitializerand used the defaultlookup, which does not see Spring beans or Spring properties.
InitParametersinVaadinHintsRegistrar, read bySpringServletwithgetDeclaredFields()SpringLookupInitializerinVaadinHintsRegistrar, checked withgetConstructors()and then calledby
LookupServletContainerInitializerVaadinHintsRegistrarTestthat check both hints