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

Add eq/hc for HttpVersionSelection #9999

Merged
merged 4 commits into from
Oct 23, 2023
Merged

Add eq/hc for HttpVersionSelection #9999

merged 4 commits into from
Oct 23, 2023

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Oct 20, 2023

Fixes #9994

@yawkat yawkat added the type: bug Something isn't working label Oct 20, 2023
@yawkat yawkat added this to the 4.1.11 milestone Oct 20, 2023
Copy link
Contributor

@graemerocher graemerocher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test

@yawkat
Copy link
Member Author

yawkat commented Oct 20, 2023

hmm not sure how to test the original bug since it's a perf issue. but i guess i can unit the class.

@jpbempel
Copy link

I think there is still an issue in io.micronaut.http.client.netty.DefaultNettyHttpClientRegistry.ClientKey::equals code related to httpVersion

            return httpVersion == clientKey.httpVersion &&

should use equals because could be different instances

Copy link
Contributor

@graemerocher graemerocher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @yawkat there is still an issue

@altro3
Copy link
Contributor

altro3 commented Oct 21, 2023

@yawkat you forgot this:

Moreover the ClientKey::equals use reference equality (==) for the httpVersion field which will be always false.

@yawkat
Copy link
Member Author

yawkat commented Oct 23, 2023

thanks @jpbempel

@yawkat
Copy link
Member Author

yawkat commented Oct 23, 2023

that one is even less testable unfortunately :(

@jpbempel
Copy link

jpbempel commented Oct 23, 2023

that one is even less testable unfortunately :(

My suggestion would be to test the call io.micronaut.http.client.netty.DefaultNettyHttpClientRegistry#getClient(io.micronaut.core.annotation.AnnotationMetadata) twice and make sure the 2 DefaultHttpClient instances are the same.
This will call getClientKey generating a ClientKey instance with the HttpVersionSelection instance generated by forClientAnnotation::forClientAnnotation

@yawkat
Copy link
Member Author

yawkat commented Oct 23, 2023

good idea!

@graemerocher graemerocher added the priority: high High priority label Oct 23, 2023
@sonarcloud
Copy link

sonarcloud bot commented Oct 23, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

60.7% 60.7% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@graemerocher graemerocher merged commit 91b96a7 into 4.1.x Oct 23, 2023
9 of 10 checks passed
@graemerocher graemerocher deleted the version-hash branch October 23, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high High priority type: bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Missing equals/hashCode in HttpVersionSelection class generates a memory leak
4 participants