yin-bo-Final opened a new issue, #16376:
URL: https://github.com/apache/dubbo/issues/16376

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   Apache Dubbo Java 3.3.7-SNAPSHOT (3.3 branch, commit c91027d), OpenJDK 17, 
Ubuntu 22.04
   
   ### Steps to reproduce this issue
   
   While reviewing the mesh routing logic, I noticed that `MeshRuleRouter` uses 
`allMatch` when evaluating the `match` list of a `DubboRouteDetail`.
   
   Add the following regression test to `MeshRuleRouterTest`:
   
   ```java
   @Test
   void routeDetailShouldMatchWhenAnyRequestMatches()
           throws ReflectiveOperationException {
       StandardMeshRuleRouter<Object> router =
               new StandardMeshRuleRouter<>(
                       url.addParameter("trafficLabel", "gray"));
   
       Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
       Map<String, Object> rule = yaml.load(
               "routedetail:\n"
                       + "  - match:\n"
                       + "      - sourceLabels: {trafficLabel: blue}\n"
                       + "      - sourceLabels: {trafficLabel: gray}\n"
                       + "    route:\n"
                       + "      - destination: {host: demo, subset: gray}\n");
   
       DubboRoute dubboRoute =
               PojoUtils.mapToPojo(rule, DubboRoute.class);
   
       assertNotNull(
               router.getDubboRouteDestination(
                       dubboRoute, new RpcInvocation()));
   }
   ```
   The required additional imports are:
   ```java
   import org.apache.dubbo.common.utils.PojoUtils;
   import 
org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.DubboRoute;
   
   import static org.junit.jupiter.api.Assertions.assertNotNull;
   ```
   Run the test:
   ```bash
   ./mvnw -pl dubbo-cluster \
     -Dtest=MeshRuleRouterTest#routeDetailShouldMatchWhenAnyRequestMatches \
     test
   ```
   The test currently fails because `getDubboRouteDestination` returns `null`.
   
   
   ### What you expected to happen
   
   The route detail should match when any entry in the `match` list matches the 
request.
   
   In this example, the first alternative (`trafficLabel=blue`) does not match, 
but the second alternative (`trafficLabel=gray`) does. Therefore, the 
configured route destination should be returned.
   
   Conditions inside a single match entry should use AND semantics, while 
multiple entries in the match list should use OR semantics.
   
   However, the current implementation uses `allMatch`, so it requires both 
mutually exclusive alternatives to match at the same time.
   
   ### Anything else
   
   The current implementation is:
   ```java
   The current implementation is:
   
   ```java
   if (matchRequestList.stream()
           .allMatch(request ->
                   request.isMatch(
                           invocation,
                           sourcesLabels,
                           tracingContextProviders))) {
       return dubboRouteDetail.getRoute();
   }
   ```
   Dubbo's mesh routing documentation states that its VirtualService semantics 
are based on and almost identical to Istio VirtualService. Istio defines 
conditions inside one match block as AND, while the list of match blocks uses 
OR semantics.
   
   ### Do you have a (mini) reproduction demo?
   
   - [x] Yes, I have a minimal reproduction demo to help resolve this issue 
more effectively!
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to