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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to