Skip to content

Commit 8f62809

Browse files
jderegclaude
andcommitted
Fix URL comparison in DeepEquals to avoid DNS resolution
Java URL.equals() performs DNS resolution which causes flaky CI failures. Now compares URLs using toExternalForm() for reliable comparison. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent be9d393 commit 8f62809

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
### Revision History
22

3+
#### 4.90.0 (Unreleased)
4+
* **BUG FIX**: `DeepEquals` - URL comparison now uses string representation instead of `URL.equals()`
5+
* Java's `URL.equals()` performs DNS resolution which causes flaky CI failures
6+
* Now compares URLs using `toExternalForm()` for reliable, deterministic comparison
7+
38
#### 4.89.0 - 2026-01-31
49
* **PERFORMANCE**: `FastReader.getLastSnippet()` now returns bounded 200-char context
510
* Previously could return 0 to 8192 characters depending on buffer position

src/main/java/com/cedarsoftware/util/DeepEquals.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ private static boolean deepEquals(Object a, Object b, Deque<ItemsToCompare> stac
607607

608608
// Handle primitive wrappers, String, Date, Class, UUID, URL, URI, Temporal classes, etc.
609609
if (Converter.isSimpleTypeConversionSupported(key1Class)) {
610+
// Special handling for URL: compare by string representation to avoid DNS resolution
611+
// Java's URL.equals() performs DNS lookup which causes flaky tests and CI failures
612+
if (key1 instanceof URL && key2 instanceof URL) {
613+
if (!((URL) key1).toExternalForm().equals(((URL) key2).toExternalForm())) {
614+
stack.addFirst(new ItemsToCompare(key1, key2, itemsToCompare, Difference.VALUE_MISMATCH));
615+
return false;
616+
}
617+
continue;
618+
}
610619
if (key1 instanceof Comparable<?> && key2 instanceof Comparable<?>) {
611620
try {
612621
if (((Comparable)key1).compareTo(key2) != 0) {

0 commit comments

Comments
 (0)