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

WFCORE-4399 ResourceEntry implementations to not implement equals/hashCode() #3722

Merged
merged 1 commit into from Apr 9, 2019

Conversation

@pferraro
Copy link
Contributor

pferraro commented Apr 3, 2019


@Override
public int hashCode() {
return this.moduleName.hashCode();

This comment has been minimized.

Copy link
@jmesnil

jmesnil Apr 5, 2019

Member

why are you not taking extensionRegistry into account?

This comment has been minimized.

Copy link
@pferraro

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.

Copy link
@jmesnil

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.

Copy link
@pferraro

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.

@jmesnil
jmesnil approved these changes Apr 8, 2019
@darranl darranl merged commit 109661f into wildfly:master Apr 9, 2019
7 checks passed
7 checks passed
Full integration - Linux Finished TeamCity Build WildFly Core / Pull Request / WildFly Core Full - Integration Linux - JDK 8 : Tests passed: 4843, ignored: 133
Details
Full integration - Windows Finished TeamCity Build WildFly Core / Pull Request / WildFly Core Full - Integration - Windows - JDK 8 : Tests passed: 4836, ignored: 138
Details
Linux - JDK 11 (Pull Request) - merge TeamCity build finished
Details
Linux - JDK 8 (Pull Request) - merge TeamCity build finished
Details
Linux - Security Manager - JDK 8 (Pull Request) - merge TeamCity build finished
Details
Windows - JDK 11 (Pull Request) - merge TeamCity build finished
Details
Windows - JDK 8 (Pull Request) - merge TeamCity build finished
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.