You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "chickenlj (GitHub)" <gi...@apache.org> on 2019/01/22 06:32:50 UTC

[GitHub] [incubator-dubbo] chickenlj opened issue #3302: Optimize compareTo in Router to guarantee consistent behaviour.

router1.compareTo(router2);
and
router2.compareTo(router1);

should always give the same order.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3302 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] lexburner commented on issue #3302: Optimize compareTo in Router to guarantee consistent behaviour.

Posted by "lexburner (GitHub)" <gi...@apache.org>.
I will fix this.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3302 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] chickenlj commented on issue #3302: Optimize compareTo in Router to guarantee consistent behaviour.

Posted by "chickenlj (GitHub)" <gi...@apache.org>.
compareTo in Router interface
```java
@Override
    default int compareTo(Router o) {
        if (o == null) {
            throw new IllegalArgumentException();
        }
        if (this.getPriority() == o.getPriority()) {
            if (o.getUrl() == null) {
                return 1;
            }
            if (getUrl() == null) {
                return -1;
            }
            return getUrl().toFullString().compareTo(o.getUrl().toFullString());
        } else {
            return getPriority() > o.getPriority() ? 1 : -1;
        }
    }
```


compareTo in ScriptRouter
```java
 @Override
    public int compareTo(Router o) {
        if (o == null || o.getClass() != ScriptRouter.class) {
            return 1;
        }
        ScriptRouter c = (ScriptRouter) o;
        return this.priority == c.priority ? rule.compareTo(c.rule) : (this.priority > c.priority ? 1 : -1);
    }
```

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3302 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] chickenlj closed issue #3302: Optimize compareTo in Router to guarantee consistent behaviour.

Posted by "chickenlj (GitHub)" <gi...@apache.org>.
[ issue closed by chickenlj ]

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3302 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org