[
https://issues.apache.org/jira/browse/WW-5540?focusedWorklogId=1031852&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1031852
]
ASF GitHub Bot logged work on WW-5540:
--------------------------------------
Author: ASF GitHub Bot
Created on: 23/Jul/26 12:41
Start Date: 23/Jul/26 12:41
Worklog Time Spent: 10m
Work Description: Copilot commented on code in PR #1808:
URL: https://github.com/apache/struts/pull/1808#discussion_r3638137918
##########
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:
`findMessageRaw` initializes `checked` and checks
`checked.contains(clazz.getName())`, but never adds the current class name to
the set. This makes the guard ineffective and can lead to redundant recursion
when traversing interface hierarchies (e.g., diamond-shaped interface
inheritance). Add the current `clazz` to `checked` after the contains-check so
the guard actually works.
Issue Time Tracking
-------------------
Worklog Id: (was: 1031852)
Time Spent: 1h 40m (was: 1.5h)
> 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 40m
> Remaining Estimate: 0h
>
> Performance enhancement
--
This message was sent by Atlassian Jira
(v8.20.10#820010)