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.



-- 
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