You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "sainadh777 (via GitHub)" <gi...@apache.org> on 2026/10/08 04:55:01 UTC

[PR] Fix attribute notification listener removal [tomcat]

sainadh777 opened a new pull request, #1079:
URL: https://github.com/apache/tomcat/pull/1079

   ## Summary
   
   - remove only the requested attribute from a `BaseModelMBean` attribute-change listener registration
   - preserve other attribute registrations, including listeners initially registered for all attributes
   - keep general notification registrations intact
   - add regression coverage and remove completed TODO item 7.1
   
   ## Rationale
   
   `BaseModelMBean.removeAttributeChangeNotificationListener(listener, name)` currently delegates to the broadcaster's listener-only removal method. That removes every registration for the listener, even though the JMX API accepts an attribute name and documents attribute-specific removal.
   
   The filter now distinguishes an explicit set of accepted names from an accept-all registration with individual exclusions. This allows one attribute to be removed without losing the remaining subscription.
   
   ## Impact
   
   The change is limited to modeler notification listener bookkeeping. It does not alter notification contents or delivery for listeners that have not removed an attribute registration.
   
   ## Validation
   
   All final gates ran with Eclipse Temurin JDK 25.0.3 in an isolated Linux Docker `overlayfs` workspace containing the exact committed sources.
   
   - `ant -Dbase.path=/tomcat-build-libs -Dexecute.validate=true validate` — passed; Checkstyle 14.3.0 reported no violations.
   - `ant -Dbase.path=/tomcat-build-libs clean && ant -Dbase.path=/tomcat-build-libs` — passed clean source build.
   - `ant -Dbase.path=/tomcat-build-libs -Dtest.entry=org.apache.tomcat.util.modeler.TestBaseModelMBean test` — passed: 4 tests, 0 failures, 0 errors, 0 skipped.
   - `ant -Dbase.path=/tomcat-build-libs -Dtest.threads=4 test` — passed: 41,548 tests across 677 reports, 0 failures, 0 errors, 362 environment/optional-feature skips.
   - Generated distribution smoke test using `bin/catalina.sh run`, `curl http://127.0.0.1:8080/`, and `bin/shutdown.sh` — HTTP 200, Tomcat process exited 0, post-stop endpoint unavailable.
   
   An initial full-suite run from a Linux container over a macOS bind mount failed only `TestDirResourceSetReadOnly.testGetResourceCaseSensitive`. The same unfiltered command passed on Docker-managed `overlayfs`, confirming the failure was the bind mount's case-insensitive filesystem semantics. An initial detached smoke run also returned HTTP 200 and shut the endpoint down, but Docker's non-reaping PID 1 left the exited Java process as a zombie; the final foreground-child smoke run above reaped the process and passed cleanly.
   


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Fix attribute notification listener removal [tomcat]

Posted by "markt-asf (via GitHub)" <gi...@apache.org>.
markt-asf commented on code in PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#discussion_r4294502354


##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -60,11 +62,15 @@ public BaseAttributeFilter(String name) {
 
 
     /**
-     * The set of attribute names that are accepted by this filter. If this list is empty, all attribute names are
-     * accepted.
+     * The set of attribute names that are accepted or excluded by this filter, depending on {@link #acceptAll}.

Review Comment:
   The comment needs to explicitly state how the value of acceptAll affects include/exclude



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -77,7 +83,11 @@ public BaseAttributeFilter(String name) {
     public void addAttribute(String name) {
 
         synchronized (names) {
-            names.add(name);
+            if (acceptAll) {
+                names.remove(name);
+            } else {
+                names.add(name);
+            }

Review Comment:
   I think a few short comments are required here to explain what is going on.



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -89,21 +99,25 @@ public void addAttribute(String name) {
     public void clear() {
 
         synchronized (names) {
+            acceptAll = true;
             names.clear();
         }
 
     }
 
 
     /**
-     * Return the set of names that are accepted by this filter. If this filter accepts all attribute names, a zero
-     * length array will be returned.
+     * Return the set of names that are explicitly accepted by this filter. If this filter is in accept-all mode,
+     * including when individual names have been excluded, a zero length array will be returned.

Review Comment:
   That is ... unexpected. Is that really the expected behavioour?



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -151,9 +161,27 @@ public boolean isNotificationEnabled(Notification notification) {
     public void removeAttribute(String name) {
 
         synchronized (names) {
-            names.remove(name);
+            if (acceptAll) {
+                names.add(name);
+            } else {
+                names.remove(name);
+            }

Review Comment:
   More comments here too



-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Document attribute listener removal fix [tomcat]

Posted by "sainadh777 (via GitHub)" <gi...@apache.org>.
sainadh777 commented on PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#issuecomment-6219347303

   @markt-asf I rebased this PR onto current main. The original implementation has been removed because e00a3d64af895fd6b66471631edafe19d4f2f74d independently fixed the issue upstream with simpler semantics and comprehensive tests, so the four inline comments are now obsolete and have been resolved. The PR now only adds the missing changelog entry and removes the completed TODO item. Validation, a clean build, and all 9 TestBaseModelMBeanNotifications tests pass. Please re-review when convenient.


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Document attribute listener removal fix [tomcat]

Posted by "sainadh777 (via GitHub)" <gi...@apache.org>.
sainadh777 commented on code in PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#discussion_r4296599080


##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -77,7 +83,11 @@ public BaseAttributeFilter(String name) {
     public void addAttribute(String name) {
 
         synchronized (names) {
-            names.add(name);
+            if (acceptAll) {
+                names.remove(name);
+            } else {
+                names.add(name);
+            }

Review Comment:
   Removed this bookkeeping; the upstream implementation does not require these branches.



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -89,21 +99,25 @@ public void addAttribute(String name) {
     public void clear() {
 
         synchronized (names) {
+            acceptAll = true;
             names.clear();
         }
 
     }
 
 
     /**
-     * Return the set of names that are accepted by this filter. If this filter accepts all attribute names, a zero
-     * length array will be returned.
+     * Return the set of names that are explicitly accepted by this filter. If this filter is in accept-all mode,
+     * including when individual names have been excluded, a zero length array will be returned.

Review Comment:
   Agreed. This behavior was removed in favor of the simpler upstream semantics.



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -60,11 +62,15 @@ public BaseAttributeFilter(String name) {
 
 
     /**
-     * The set of attribute names that are accepted by this filter. If this list is empty, all attribute names are
-     * accepted.
+     * The set of attribute names that are accepted or excluded by this filter, depending on {@link #acceptAll}.

Review Comment:
   Removed this implementation. The upstream fix avoids include/exclude state entirely.



##########
java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java:
##########
@@ -151,9 +161,27 @@ public boolean isNotificationEnabled(Notification notification) {
     public void removeAttribute(String name) {
 
         synchronized (names) {
-            names.remove(name);
+            if (acceptAll) {
+                names.add(name);
+            } else {
+                names.remove(name);
+            }

Review Comment:
   Removed this code path, so the additional explanatory comments are no longer needed.



-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Document attribute listener removal fix [tomcat]

Posted by "markt-asf (via GitHub)" <gi...@apache.org>.
markt-asf commented on PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#issuecomment-6265080396

   @rmaucher opted not to add a change log entry. I've updated the TODO list.


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Fix attribute notification listener removal [tomcat]

Posted by "sainadh777 (via GitHub)" <gi...@apache.org>.
sainadh777 commented on PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#issuecomment-6052581983

   @rmaucher and @markt-asf, could you please review this modeler listener-bookkeeping fix? Rémy has the most recent substantive history on BaseModelMBean and BaseNotificationBroadcaster, while Mark has recent history across all three modified modeler classes. GitHub did not permit formal review requests from this fork.


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Document attribute listener removal fix [tomcat]

Posted by "markt-asf (via GitHub)" <gi...@apache.org>.
markt-asf closed pull request #1079: Document attribute listener removal fix
URL: https://github.com/apache/tomcat/pull/1079


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Document attribute listener removal fix [tomcat]

Posted by "rmaucher (via GitHub)" <gi...@apache.org>.
rmaucher commented on PR #1079:
URL: https://github.com/apache/tomcat/pull/1079#issuecomment-6266317099

   Right, this was part of code review issues found. There are many many issues, so when they realistically affect nobody I am not adding an explicit changelog entry.


-- 
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: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org