sepe81 commented on a change in pull request #460:
URL: https://github.com/apache/struts/pull/460#discussion_r547986265



##########
File path: 
core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
##########
@@ -308,36 +305,90 @@ protected void reloadBundles(Map<String, Object> context) 
{
         }
     }
 
+    /**
+     * A helper method for {@link ResourceBundle} bundle reload logic.
+     * 
+     * Uses standard {@link ResourceBundle} methods to clear the bundle caches 
for the 
+     * {@link ClassLoader} instances that this class is aware of at the time 
of the call.
+     * 
+     * The <code>clearCache()</code> methods have been available since Java 
1.6, so 
+     * it is anticipated the logic will work on any subsequent JVM versions.
+     * 
+     * @since 2.6
+     */
+    private void clearResourceBundleClassloaderCaches() {
+        final ClassLoader ccl = getCurrentThreadContextClassLoader();
+        ResourceBundle.clearCache();     // Bundles loaded by the caller's 
classloader.
+        ResourceBundle.clearCache(ccl);  // Bundles loaded by the context 
classloader (may be the same).
+        // Clear the bundle cache for any non-null delegated classloaders.
+        delegatedClassLoaderMap.forEach( (key, value) -> { if (value != null) 
ResourceBundle.clearCache(value) ;} );
+    }
+
+    /**
+     * "Hacky" helper method that attempts to clear the Tomcat 
<code>ResourceEntry</code>
+     * {@link Map} using knowledge of the Tomcat source code.
+     * 
+     * It relies on the {@link #TOMCAT_RESOURCE_ENTRIES_FIELD} field name, 
base class name 
+     * {@link #TOMCAT_WEBAPP_CLASSLOADER_BASE}. and descendant class names 
{@link #TOMCAT_WEBAPP_CLASSLOADER},
+     * {@link #TOMCAT_PARALLEL_WEBAPP_CLASSLOADER}, to keep the values 
identified in the constants.
+     * It appears to be valid for Tomcat versions 7-10 so far, but could 
become invalid at any time in the future
+     * when the resource handling logic in Tomcat changes.
+     * 
+     * Note: With Java 9+, calling this method may result in "Illegal 
reflective access" warnings.  Be aware 
+     *       its logic may fail in a future version of Java that blocks the 
reflection calls needed for this method.
+     * {<code></code>

Review comment:
       ```suggestion
   ```
   
   this line can probably be omitted




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

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


Reply via email to