From 7f90df7f9b4cf3db9abe6ce33ea55c9602012d3c Mon Sep 17 00:00:00 2001 From: cpovirk Date: Tue, 16 Jul 2024 09:42:08 -0700 Subject: [PATCH] Improve docs for `URLEqualsHashCode`. PiperOrigin-RevId: 652878662 --- docs/bugpattern/URLEqualsHashCode.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/bugpattern/URLEqualsHashCode.md b/docs/bugpattern/URLEqualsHashCode.md index 1427964c370..aac6cfb9de0 100644 --- a/docs/bugpattern/URLEqualsHashCode.md +++ b/docs/bugpattern/URLEqualsHashCode.md @@ -1,2 +1,7 @@ -Equals and HashCode method of java.net.URL make blocking network calls. Either -use java.net.URI or if that isn't possible, use Collection or List. +The `equals` and `hashCode` methods of `java.net.URL` make blocking network +calls. When you place a `URL` into a hash-based container, the container invokes +those methods. + +Prefer `java.net.URI`. Or, if you must use `URL` in a +collection, prefer to use a non-hash-based container like a `List`, and +avoid calling methods like `contains` (which calls `equals`) on it.