Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upWFCORE-4399 ResourceEntry implementations to not implement equals/hashCode() #3722
Conversation
…hCode()
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return this.moduleName.hashCode(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pferraro
Apr 5, 2019
•
Author
Contributor
Because the path element (specifically the moduleName, as all extensions will have use same path key) of an extension's ResourceEntry is sufficient to identify uniqueness.
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return this.getPathElement().hashCode(); |
This comment has been minimized.
This comment has been minimized.
jmesnil
Apr 5, 2019
Member
Shouldn't the hashCode take into account the delegate's hashCode()?
It seems to me that 2 instances of DelegateResource with the same path element but different delegate should not be considered identical.
This comment has been minimized.
This comment has been minimized.
pferraro
Apr 5, 2019
•
Author
Contributor
Don't confuse the hashCode/equals implementation of a ResourceEntry with that of a Resource. A ResourceEntry is a Resource located at a specific path.
A Set should never contain multiple Resource implementations with the same path. Otherwise, the semantics of Resource.getChildren(...) would be ambiguous.
It seems to me that 2 instances of DelegateResource with the same path element but different delegate should not be considered identical.
Please refer back to the premise of the jira. If I have a hash-based Set containing the ResourceEntry's of a given child type (e.g. the result of Resource.getChildren(String childType), and I want to replace one of the entries with a different Resource implementation (typically by decorating the one that exists for a given path), I cannot do this unless the PathElement of the ResourceEntry is what identifies it in the set.
109661f
into
wildfly:master
pferraro commentedApr 3, 2019
https://issues.jboss.org/browse/WFCORE-4399