Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial attempt to address WW-5101 #460

Conversation

JCgH4164838Gh792C124B5
Copy link
Contributor

Initial attempt to address WW-5101

  • Add comments to methods related to ResourceBundle cache clearing.
  • Correct clearTomcatCache() so that it acts as intended for Tomcat 7-10.
  • Add clearResourceBundleClassloaderCaches() method that uses standard Java API calls to perform the cache clearing.
  • Adjust clearMap() logic to only change accessiblity when required.

- Add comments to methods related to ResrouceBundle cache clearing.
- Correct clearTomcatCache() so that it acts as intended for Tomcat 7-10.
- Add clearResourceBundleClassloaderCaches() method that uses standard Java
API calls to perform the cache clearing.
- Adjust clearMap() logic to only change accessiblity when required.
@JCgH4164838Gh792C124B5
Copy link
Contributor Author

Hello Apache Struts Team.

This is an an initial attempt to address the reported issue. Basic local testing indicates it is working, with no illegal reflective access warnings seen with Java 11. People may decide to eventually remove the clearTomcatCache() method in the future, but for the moment this PR attempts to correct its behaviour so that it acts as the previous code and comments indicate it should.

Please let me know if the PR looks OK when you have time.

@coveralls
Copy link

coveralls commented Dec 22, 2020

Coverage Status

Coverage increased (+0.03%) to 49.811% when pulling 2020e2f on JCgH4164838Gh792C124B5:localS2_26_WW-5101_cleanupfix1 into 7532d2f on apache:master.

*
* 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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {<code></code>

this line can probably be omitted


try {
if ("org.apache.catalina.loader.WebappClassLoader".equals(cl.getName())) {
clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
if ( (TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( (TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) &&
if ((TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) &&

consistent formatting

if ("org.apache.catalina.loader.WebappClassLoader".equals(cl.getName())) {
clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
if ( (TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) &&
(superCl != null && TOMCAT_WEBAPP_CLASSLOADER_BASE.equals(superCl.getName())) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(superCl != null && TOMCAT_WEBAPP_CLASSLOADER_BASE.equals(superCl.getName())) ) {
(superCl != null && TOMCAT_WEBAPP_CLASSLOADER_BASE.equals(superCl.getName()))) {

- Changed formatting as per review.
- Added null guard for unlikely dereference in clearTomcatCache() logging
statement.
- Added a unit test for basic correctness check and better code coverage.
Copy link
Member

@lukaszlenart lukaszlenart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@lukaszlenart
Copy link
Member

No complains, so let's merge!

@lukaszlenart lukaszlenart merged commit 2139909 into apache:master Jan 2, 2021
@JCgH4164838Gh792C124B5 JCgH4164838Gh792C124B5 deleted the localS2_26_WW-5101_cleanupfix1 branch January 3, 2021 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants