[
https://issues.apache.org/jira/browse/WW-5540?focusedWorklogId=1032255&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1032255
]
ASF GitHub Bot logged work on WW-5540:
--------------------------------------
Author: ASF GitHub Bot
Created on: 26/Jul/26 03:04
Start Date: 26/Jul/26 03:04
Worklog Time Spent: 10m
Work Description: lukaszlenart commented on code in PR #1808:
URL: https://github.com/apache/struts/pull/1808#discussion_r3651618083
##########
core/src/main/java/org/apache/struts2/text/AbstractLocalizedTextProvider.java:
##########
@@ -519,86 +584,165 @@ protected String getMessage(String bundleName, Locale
locale, String key, ValueS
reloadBundles(valueStack.getContext());
}
try {
- String message = bundle.getString(key);
- if (valueStack != null) {
- message =
TextParseUtil.translateVariables(bundle.getString(key), valueStack);
- }
- MessageFormat mf = buildMessageFormat(message, locale);
- return formatWithNullDetection(mf, args);
+ String rawPattern = bundle.getString(key);
+ return formatMessage(rawPattern, locale, valueStack, args);
} catch (MissingResourceException e) {
LOG.debug("Missing key [{}] in bundle [{}]!", key, bundleName);
return null;
}
}
/**
- * Traverse up class hierarchy looking for message. Looks at class, then
implemented interface,
- * before going up hierarchy.
- *
- * @return the message
+ * Raw-pattern twin of {@link #findMessage}. Walks class, implemented
interfaces, then up the
+ * hierarchy, returning the first raw message pattern found (via {@link
#getRawMessage}) without
+ * translation or formatting. Used by the cached class-hierarchy resolver.
*/
- protected String findMessage(Class<?> clazz, String key, String
indexedKey, Locale locale, Object[] args, Set<String> checked,
- ValueStack valueStack) {
+ private String findMessageRaw(Class<?> clazz, String key, String
indexedKey, Locale locale, Set<String> checked) {
if (checked == null) {
checked = new TreeSet<>();
} else if (checked.contains(clazz.getName())) {
return null;
}
Review Comment:
Good catch — fixed in eff4a42e0. You're right that `checked` tested
`contains(clazz.getName())` but never added the class, making the
diamond-interface cycle guard a no-op. (It's actually a pre-existing latent
issue: the original `findMessage` on `main` has the same dead guard, which this
raw twin mirrored.) Now the class name is recorded right after the
contains-check, so redundant re-traversal is avoided. Behavior is unchanged
since message lookups are idempotent, and because the deprecated `findMessage`
delegates to `findMessageRaw`, both paths are fixed.
Issue Time Tracking
-------------------
Worklog Id: (was: 1032255)
Time Spent: 1h 50m (was: 1h 40m)
> Add caching to AbstractLocalizedTextProvider
> --------------------------------------------
>
> Key: WW-5540
> URL: https://issues.apache.org/jira/browse/WW-5540
> Project: Struts 2
> Issue Type: Improvement
> Components: Core
> Affects Versions: 6.7.4, 7.0.3
> Reporter: Kusal Kithul-Godage
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 7.3.0
>
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> Performance enhancement
--
This message was sent by Atlassian Jira
(v8.20.10#820010)