You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid merging message bundle and attributes into a new map - #52991
FreeMarkerLoginFormsProvider used to merge the message bundle and template attributes into a new HashMap on every page render, even though the result is only used for read-only lookups.
Replaced the merge with MessageAttributeProperties, a read-only Properties view that checks the message bundle first and falls back to the template attributes, without copying either source.
This is a deliberate, not just incidental, behavior change: attribute lookups now reflect the attributes map as of render time (via a live reference) instead of a snapshot taken when the view was constructed. FreeMarkerLoginFormsProvider.processTemplate() resolves native FreeMarker ${...} expressions against the same, fully-populated attributes map only after createCommonAttributes() finishes running.
A ${...} placeholder embedded inside a translated message string now resolves consistently with the same placeholder written directly in a template file, closing a previous inconsistency where only the message-string path saw an earlier, incomplete snapshot.
FreeMarkerLoginFormsProvider used to merge the message bundle and template
attributes into a new HashMap on every page render, even though the
result is only used for read-only lookups.
Replaced the merge with MessageAttributeProperties, a read-only
Properties view that checks the message bundle first and falls back
to the template attributes, without copying either source.
Closeskeycloak#52990
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This live reference changes the behavior that #52990 requires preserving: the previous new HashMap<>(attributes) (followed by the MessageFormatterMethod(Map) copy) snapshotted entries before createCommonAttributes() and the attribute mapper ran, whereas this view exposes later additions and replacements. That can change ${...} substitutions in custom messages; please retain the original snapshot semantics while removing the full merge, or explicitly revise the requirement if this behavior change is intended.
Re: the "Previously missed" finding about preserving attribute snapshot semantics (MessageAttributeProperties.java:43).
This is a deliberate behavior change, not an oversight. FreeMarkerLoginFormsProvider.processTemplate() resolves native FreeMarker ${...} expressions directly against attributes, but only after createCommonAttributes() has finished populating it. The old snapshot (taken much earlier, in handleThemeResources()) meant a ${...} placeholder embedded inside a translated message string could see a different, incomplete view of attributes than the exact same placeholder written directly in a template file. The live reference removes that inconsistency: both paths now resolve attributes as of render time.
Updated #52990's Goals section and this PR's description to state this explicitly, and reworded the Javadoc/test in the latest commit to document the reasoning instead of only describing the mechanism.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FreeMarkerLoginFormsProvider used to merge the message bundle and template attributes into a new HashMap on every page render, even though the result is only used for read-only lookups.
Replaced the merge with MessageAttributeProperties, a read-only Properties view that checks the message bundle first and falls back to the template attributes, without copying either source.
This is a deliberate, not just incidental, behavior change: attribute lookups now reflect the attributes map as of render time (via a live reference) instead of a snapshot taken when the view was constructed.
FreeMarkerLoginFormsProvider.processTemplate()resolves native FreeMarker${...}expressions against the same, fully-populated attributes map only aftercreateCommonAttributes()finishes running.A
${...}placeholder embedded inside a translated message string now resolves consistently with the same placeholder written directly in a template file, closing a previous inconsistency where only the message-string path saw an earlier, incomplete snapshot.Closes #52990