Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL被重复添加没有正确修复 #7375

Closed
brucelwl opened this issue Mar 15, 2021 · 3 comments
Closed

URL被重复添加没有正确修复 #7375

brucelwl opened this issue Mar 15, 2021 · 3 comments

Comments

@brucelwl
Copy link
Contributor

brucelwl commented Mar 15, 2021

这个issue #4587 对应的修复https://github.com/apache/dubbo/pull/6706/files 不正确,仍然会导致URL被重复添加,
原因是重写hashCode方法将parameters 全部计算了, 没有剔除timestamp
https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java#L1663

@kevinw66
Copy link
Contributor

看看这样解决是不是能行 #7376

@brucelwl
Copy link
Contributor Author

看看这样解决是不是能行 #7376

可以,但是遍历方式不是很好,建议换成这样

private int parametersHashCode() {
        int h = 0;
        for (Map.Entry<String, String> next : parameters.entrySet()) {
            if (Constants.TIMESTAMP_KEY.equals(next.getKey())) {
                continue;
            }
            h += next.hashCode();
        }
        return h;
    }

@kevinw66
Copy link
Contributor

看看这样解决是不是能行 #7376

可以,但是遍历方式不是很好,建议换成这样

private int parametersHashCode() {
        int h = 0;
        for (Map.Entry<String, String> next : parameters.entrySet()) {
            if (Constants.TIMESTAMP_KEY.equals(next.getKey())) {
                continue;
            }
            h += next.hashCode();
        }
        return h;
    }

已改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants