-
Notifications
You must be signed in to change notification settings - Fork 531
Add default hashCode implementation to RetryConfiguration.AnnotationClassOrMethodPointcut #472
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 default hashCode implementation to RetryConfiguration.AnnotationClassOrMethodPointcut #472
Conversation
@NorsaG Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@NorsaG Thank you for signing the Contributor License Agreement! |
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.
Update Copyright of the changed class to actual year.
Add you name to the @author
list.
Thanks
src/main/java/org/springframework/retry/annotation/RetryConfiguration.java
Outdated
Show resolved
Hide resolved
dfc2ee9
to
492e03d
Compare
…ssOrMethodPointcut
80d4edf
to
b4c9058
Compare
Fit the PR according to the comment. |
@NorsaG , thank you for contribution; looking forward for more! |
@artembilan, I’ve finally published an article with a detailed explanation of a real-world case of this issue: https://shorturl.at/HVa0Y |
Hi @NorsaG ! The article is great! Would you mind from your experience point me where exactly that Thank you! |
@artembilan Yes, of course. I've tried to reproduce the same problem again. It was a bit tricky due to the complexity of our project and the ongoing component upgrades. In Picture 1, you can observe the LoadingCache object at the moment of retrieving an object from the cache (I paused at a debug point after several configuration updates from the config server). In Picture 2, nothing is found in the cache. In Picture 3, I have highlighted the path to the pointcut. (I'm not entirely sure, but I highlighted the "methodMatcherKey" string because it is unique for all EnhancerKeys in the cache.) |
Thanks. I see now.
Where one of them is our
So, apparently the problem has gone with that our I see how this was hard to catch and even harder to determine what simple fix has to be. Thank you again! I will look now to other |
That was a really interesting issue! It was a bit of a pain to track down the cause since the production service wasn’t accessible, but I’m happy I could help out |
I was wrong with that sentence:
It is not about properties, but object identity by default: https://varoa.net/jvm/java/openjdk/biased-locking/2017/01/30/hashCode.html. And you were right, the
That
and that default
So, that's where we got that discrepancy because default |
I read the article above, but in my opinion, the author described a some different set of issues. According to the official API note:
Source: Object.equals() documentation This was a significant problem in our case. Another point is the |
I think |
This pull request introduces a default implementation of
hashCode
forRetryConfiguration.AnnotationClassOrMethodPointcut
.I discovered that using Spring Cloud with configuration refreshing (specifically the
@RefreshScope
annotation andConfigServicePropertySourceLocator
as part of spring-cloud-config) can lead to a "java.lang.OutOfMemoryError: Metaspace". This occurs because theConfigServicePropertySourceLocator
is re-initialized with every refresh. Due to the absence of ahashCode
implementation, proxies for this class are regenerated each time, which causes them to be stored in theorg.springframework.cglib.core.internal.LoadingCache
(withRetryConfiguration.AnnotationClassOrMethodPointcut
being part of the composite key for this object).This results in an excessive accumulation of generated proxies in memory, ultimately leading to metaspace overflow.