You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "63914578 (GitHub)" <gi...@apache.org> on 2018/11/17 03:01:23 UTC

[GitHub] [incubator-dubbo] 63914578 opened issue #2799: Router compareTo 方法实现引发异常

- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.6.2
* Operating System version: Linux
* Java version: 8

### Steps to reproduce this issue

1. 添加路由
2. 指定相同的priority
3. 引发异常:java.lang.IllegalArgumentException: Comparison method violates its general contract! 
查看源码 ConditionRouter、ScriptRouter、TagRouter 的 compareTo 方法实现类似,会引发同类问题。

Pls. provide [GitHub address] to reproduce this issue.

### Expected Result

What do you expected from the above steps?

### Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

```
ERROR com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry  -  [DUBBO] Failed to notify for subscribe consumer://xx.xx.xx.xx/com.xxx.service.XxxService?application=xxx-service&category=providers,configurators,routers&default.check=true&dubbo=2.6.2&interface=com.xxx.service.XxxService&methods=getXxx,setXxx&owner=xxx&pid=160275&revision=3.5.9&side=consumer&timeout=10000×tamp=1542092651604, waiting for retry, cause: Comparison method violates its general contract!, dubbo version: 2.6.2, current host: xx.xx.xx
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.ComparableTimSort.mergeLo(ComparableTimSort.java:740)
	at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:477)
	at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:402)
	at java.util.ComparableTimSort.sort(ComparableTimSort.java:209)
	at java.util.Arrays.sort(Arrays.java:1312)
	at java.util.Arrays.sort(Arrays.java:1506)
	at java.util.ArrayList.sort(ArrayList.java:1454)
	at java.util.Collections.sort(Collections.java:141)
	at com.alibaba.dubbo.rpc.cluster.directory.AbstractDirectory.setRouters(AbstractDirectory.java:110)
	at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:211)
	at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:414)
	at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:274)
	at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:260)
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:190)
	at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:190)
	at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:159)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:305)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:286)
	at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:63)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:106)
	at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:65)
	at com.alibaba.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
	at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:394)
	at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:333)
	at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:163)
	at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:66)
```


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

[GitHub] [incubator-dubbo] carryxyh commented on issue #2799: Router compareTo 方法实现引发异常

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
Personally think it is indeed a problem.
Here you can find the [incompatibility list](https://www.oracle.com/technetwork/java/javase/compatibility-417013.html#incompatibilities) of JDK6 and 7, which contains the sorting problem of Collections.
In the 1.7 version, the problem you describe will be thrown, and will not be thrown in 1.6. We need to optimize this problem, allowing the same priority to be specified.

@63914578 
Can you submit a pr to fix this problem?

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


[GitHub] [incubator-dubbo] AnyOSR commented on issue #2799: Router compareTo 方法实现引发异常

Posted by "AnyOSR (GitHub)" <gi...@apache.org>.
不让指定相同的priority是正常的吧?要不然怎么确保确定的顺序?

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

[GitHub] [incubator-dubbo] beiwei30 closed issue #2799: Router compareTo 方法实现引发异常

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

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