You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Tommy Lindgren (Jira)" <ji...@apache.org> on 2024/11/26 16:03:00 UTC

[jira] [Updated] (ARTEMIS-5182) Stomp connection may use bad selector when noLocal is enabled

     [ https://issues.apache.org/jira/browse/ARTEMIS-5182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tommy Lindgren updated ARTEMIS-5182:
------------------------------------
    Description: 
If {{noLocal}} is enabled, {{StompConnection.java}} adds {{ AND AMQ_CID<>xxx}} to the selector _without_ wrapping the original expression in parentheses which means not all messages sent to the topic are filtered properly.

For example, if the original selector is {{{}foo=1 or bar=2{}}}, the new selector will be {{foo=1 or bar=2 and __AMQ_CID<>xxx}}, so messages with only {{foo=1}} won't respect {{noLocal}}.

Untested potential patch:
{noformat}
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 742c2a8d79..8527eea8a2 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -566,7 +566,7 @@ public final class StompConnection extends AbstractRemotingConnection {
          if (selector == null) {
             selector = noLocalFilter;
          } else {
-            selector += " AND " + noLocalFilter;
+            selector = "(" + selector + ") AND " + noLocalFilter;
          }
       }{noformat}
 

  was:
If {{noLocal}} is enabled, {{StompConnection.java}} adds{{{} AND _{}}}{_}{{AMQ_CID<>xxx}}{_} to the selector _without_ wrapping the original expression in parentheses which means not all messages sent to the topic are filtered properly.

For example, if the original selector is {{{}foo=1 or bar=2{}}}, the new selector will be {{{}foo=1 or bar=2 and __AMQ_CID<>xxx{}}}, so messages with only{{ foo=1}} won't respect {{{}noLocal{}}}.

Untested potential patch:
{noformat}
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 742c2a8d79..8527eea8a2 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -566,7 +566,7 @@ public final class StompConnection extends AbstractRemotingConnection {
          if (selector == null) {
             selector = noLocalFilter;
          } else {
-            selector += " AND " + noLocalFilter;
+            selector = "(" + selector + ") AND " + noLocalFilter;
          }
       }{noformat}
 


> Stomp connection may use bad selector when noLocal is enabled
> -------------------------------------------------------------
>
>                 Key: ARTEMIS-5182
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5182
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: STOMP
>    Affects Versions: 2.37.0
>            Reporter: Tommy Lindgren
>            Assignee: Justin Bertram
>            Priority: Major
>
> If {{noLocal}} is enabled, {{StompConnection.java}} adds {{ AND AMQ_CID<>xxx}} to the selector _without_ wrapping the original expression in parentheses which means not all messages sent to the topic are filtered properly.
> For example, if the original selector is {{{}foo=1 or bar=2{}}}, the new selector will be {{foo=1 or bar=2 and __AMQ_CID<>xxx}}, so messages with only {{foo=1}} won't respect {{noLocal}}.
> Untested potential patch:
> {noformat}
> diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
> index 742c2a8d79..8527eea8a2 100644
> --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
> +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
> @@ -566,7 +566,7 @@ public final class StompConnection extends AbstractRemotingConnection {
>           if (selector == null) {
>              selector = noLocalFilter;
>           } else {
> -            selector += " AND " + noLocalFilter;
> +            selector = "(" + selector + ") AND " + noLocalFilter;
>           }
>        }{noformat}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@activemq.apache.org
For additional commands, e-mail: issues-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact