This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new a10df2f7e fix(router): preserve v3.0 condition flags (#3658)
a10df2f7e is described below

commit a10df2f7e1407b9116c15d14392504e9276080e6
Author: xiaobaicai66695 <[email protected]>
AuthorDate: Fri Aug 14 08:38:21 2026 +0800

    fix(router): preserve v3.0 condition flags (#3658)
    
    Fixes apache/dubbo-go#3656.
---
 cluster/router/condition/dynamic_router.go |  2 +-
 cluster/router/condition/router_test.go    | 68 ++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/cluster/router/condition/dynamic_router.go 
b/cluster/router/condition/dynamic_router.go
index e238bf530..4102005a5 100644
--- a/cluster/router/condition/dynamic_router.go
+++ b/cluster/router/condition/dynamic_router.go
@@ -293,7 +293,7 @@ func generateConditionsRoute(rawConfig string) 
(stateRouters, bool, bool, error)
                return nil, false, false, err
        }
 
-       force, enable := *routerConfig.Enabled, *routerConfig.Force
+       force, enable := *routerConfig.Force, *routerConfig.Enabled
        if !enable {
                return nil, false, false, nil
        }
diff --git a/cluster/router/condition/router_test.go 
b/cluster/router/condition/router_test.go
index d7dd21f74..509801e35 100644
--- a/cluster/router/condition/router_test.go
+++ b/cluster/router/condition/router_test.go
@@ -187,6 +187,74 @@ func TestDynamicRouterSetStaticConfig(t *testing.T) {
        })
 }
 
+func TestGenerateConditionsRoutePreservesExplicitBooleans(t *testing.T) {
+       raw := `conditions:
+- method=SayHello => application=router-rule-e2e-condition-provider-hangzhou
+configVersion: v3.0
+enabled: true
+force: false
+key: org.apache.dubbo.quickstart.Greeter:1.0.0:demo
+priority: 1
+runtime: true
+scope: service
+`
+
+       routers, force, enabled, err := generateConditionsRoute(raw)
+       require.NoError(t, err)
+       assert.False(t, force)
+       assert.True(t, enabled)
+       assert.Len(t, routers, 1)
+}
+
+func TestDynamicRouterSwitchesFromV31ToV30(t *testing.T) {
+       providerHangzhou, err := common.NewURL(
+               "dubbo://127.0.0.1:20000/org.apache.dubbo.quickstart.Greeter" +
+                       
"?application=router-rule-e2e-condition-provider-hangzhou&group=demo&version=1.0.0",
+       )
+       require.NoError(t, err)
+       providerShanghai, err := common.NewURL(
+               "dubbo://127.0.0.1:20001/org.apache.dubbo.quickstart.Greeter" +
+                       
"?application=router-rule-e2e-condition-provider-shanghai&group=demo&version=1.0.0",
+       )
+       require.NoError(t, err)
+       consumer, err := common.NewURL(
+               
"consumer://127.0.0.1/org.apache.dubbo.quickstart.Greeter?group=demo&version=1.0.0",
+       )
+       require.NoError(t, err)
+       invokers := []base.Invoker{base.NewBaseInvoker(providerHangzhou), 
base.NewBaseInvoker(providerShanghai)}
+
+       d := &DynamicRouter{}
+       d.Process(&config_center.ConfigChangeEvent{
+               Value: `configVersion: v3.1
+enabled: true
+force: false
+conditions:
+  - from:
+      match: method=SayHello
+    to:
+      - match: application=router-rule-e2e-condition-provider-shanghai
+        weight: 100
+`,
+               ConfigType: remoting.EventTypeUpdate,
+       })
+       got := d.Route(invokers, consumer, 
invocation.NewRPCInvocation("SayHello", nil, nil))
+       require.Len(t, got, 1)
+       assert.Equal(t, "router-rule-e2e-condition-provider-shanghai", 
got[0].GetURL().GetParam("application", ""))
+
+       d.Process(&config_center.ConfigChangeEvent{
+               Value: `configVersion: v3.0
+enabled: true
+force: false
+conditions:
+  - method=SayHello => application=router-rule-e2e-condition-provider-hangzhou
+`,
+               ConfigType: remoting.EventTypeUpdate,
+       })
+       got = d.Route(invokers, consumer, 
invocation.NewRPCInvocation("SayHello", nil, nil))
+       require.Len(t, got, 1)
+       assert.Equal(t, "router-rule-e2e-condition-provider-hangzhou", 
got[0].GetURL().GetParam("application", ""))
+}
+
 func TestScopedStaticConfigSetters(t *testing.T) {
        t.Run("service router only accepts service scope", func(t *testing.T) {
                router := NewServiceRouter()

Reply via email to