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

Replace URL with String as the key #1038

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

iamyulong
Copy link
Member

The equals() implementation of URL resolves the hostname into an IP address. When multiple URLs are mapped into the same IP (especially with 1.1.1.1 DNS server), it will cause the following exception:

java.lang.IllegalArgumentException: Multiple entries with same key: https://ifconfig.co/ip=Success(x.x.x.x) and https://www.trackip.net/ip=Success(x.x.x.x)
        at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:377)
        at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:371)
        at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:241)
        at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:132)
        at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:94)
        at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:573)
        at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:601)
        at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:588)
        at com.radixdlt.p2p.hostip.NetworkQueryHostIp.get(NetworkQueryHostIp.java:191)

The equals() implementation of URL resolves the hostname into an IP address.
When multiple URLs are mapped into the same IP (especially with 1.1.1.1 DNS server),
it will cause the following exception:
```
java.lang.IllegalArgumentException: Multiple entries with same key
```
Copy link

Phylum Report Link

Copy link

github-actions bot commented Nov 29, 2024

Docker tags
docker.io/radixdlt/private-babylon-node:pr-1038
docker.io/radixdlt/private-babylon-node:5a5951d6db
docker.io/radixdlt/private-babylon-node:sha-5a5951d

Copy link
Contributor

@dhedey dhedey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, subject to fixing NetworkQueryHostIpTest.java so the tests compile and run

@iamyulong iamyulong force-pushed the feature/fix-ip-clash branch from 1070b4e to 02ea27b Compare November 29, 2024 15:00
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 42.4%. Comparing base (3eb74c0) to head (02ea27b).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##             release/cuttlefish   #1038   +/-   ##
====================================================
  Coverage                  42.4%   42.4%           
- Complexity                 4624    4628    +4     
====================================================
  Files                      1782    1782           
  Lines                     55167   55159    -8     
  Branches                   1524    1524           
====================================================
+ Hits                      23406   23407    +1     
+ Misses                    31282   31274    -8     
+ Partials                    479     478    -1     
Flag Coverage Δ
rust 42.4% <100.0%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...va/com/radixdlt/p2p/hostip/NetworkQueryHostIp.java 92.5% <100.0%> (+11.2%) ⬆️

... and 2 files with indirect coverage changes

@iamyulong iamyulong merged commit 7440dd4 into release/cuttlefish Dec 2, 2024
22 checks passed
@iamyulong iamyulong deleted the feature/fix-ip-clash branch December 2, 2024 13:22
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

Successfully merging this pull request may close these issues.

3 participants