-
Notifications
You must be signed in to change notification settings - Fork 1k
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 supplier variant for Observation.Context.getOrDefault() #3708
Conversation
* @param <T> value type | ||
* @return object or default if not present | ||
*/ | ||
<T> T getOrDefault(Object key, Supplier<T> defaultObjectSupplier); |
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.
I guess that should be a default method of we don't want to break current users (assuming that anyone has ever created their own implementation of ObservationRegistry)
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.
@marcingrzejszczak Thanks for the feedback! I updated this based on your feedback.
Ah, one more thing - can you please add a test for this? |
* @param defaultObjectSupplier supplier for default object to return | ||
* @param <T> value type | ||
* @return object or default if not present | ||
*/ |
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.
Could you please add @since 1.11.0
?
@marcingrzejszczak @jonatan-ivanov Thanks! I applied your reviews in e11b3bd. |
This PR adds a supplier variant for
Observation.Context.getOrDefault()
to avoid default object creation where unnecessary.