-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Docs: note ClassPath.getResources keeps one entry per path - #8608
Docs: note ClassPath.getResources keeps one entry per path #8608Hashim1999164 wants to merge 1 commit into
Conversation
@MuhammadNiazAli
MuhammadNiazAli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh naya repo/PR hai google/guava #8608 (abhi tak Open hai, achha hai review submit ho sakega). Chaliye review likhte hain:
Review:
This is a small but genuinely useful doc fix clarifying getResources()'s dedup behavior can save someone real debugging time if they assumed every resource on the classpath shows up in the result.
Removing "all" from the first line: Good catch. The old wording "Returns all resources loadable..." — was misleading precisely because the method does not return every resource; it keeps only one entry per path. Dropping "all" makes the opening line accurate instead of contradicting the new paragraph you added right below it.
New paragraph is clear and specific: "instances are equal when they share the same resource name and ClassLoader... only one resource is kept for a given path even if that path appears in multiple jars or directories" this explains both why (equality based on name + ClassLoader) and what the practical effect is (last-one-wins-ish dedup across jars). That's exactly the kind of detail that's easy to discover the hard way and hard to find in existing docs.
One small thing worth checking: since dedup is based on equality of ResourceInfo (name + ClassLoader), it might be worth a one-line note on which entry wins when the same path appears in multiple jars (first one found on the classpath order, presumably) this could matter for someone debugging a "which jar's resource am I actually getting" issue. Not blocking, but it's the natural next question a reader would have after this paragraph.
Scope is right: pure Javadoc change, one file, no logic touched exactly what a "Docs:" prefixed PR should be.
Nit aside, this is a solid, well-scoped documentation clarification. Looks good to approve.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Fixes #2712
Clarifies
ClassPath.getResources()so callers know thatResourceInfoequality is by resource name and class loader, and that the returnedImmutableSettherefore keeps only one resource for a given path even when that path appears in multiple jars or directories.Test plan
getResourcesJavadoc