Repository navigation
Improve nullability for gauges - #6546
Merged
jonatan-ivanov merged 1 commit intoJul 17, 2025
Merged
Conversation
izeye
force-pushed
the
contracts-for-gauges
branch
2 times, most recently
from
July 17, 2025 14:43
3b2355a to
42023ac
Compare
izeye
commented
Jul 17, 2025
| * @return The number that was passed in so the registration can be done as part of an | ||
| * assignment statement. | ||
| */ | ||
| @Contract("_, _, !null -> !null") |
Contributor
Author
There was a problem hiding this comment.
There are some inconsistencies including this. If the state object (number) being non-null is intentional, dropping @Nullable seems to be better.
Contributor
Author
There was a problem hiding this comment.
I just dropped @Nullable annotations for these cases instead.
| * assignment statement. | ||
| */ | ||
| @Contract("_, _, !null, _ -> !null") | ||
| public static <T> @Nullable T gauge(String name, Iterable<Tag> tags, T obj, ToDoubleFunction<T> valueFunction) { |
Contributor
Author
There was a problem hiding this comment.
There is another inconsistency: the state object in the corresponding method in the MeterRegistry is nullable while this state object (obj) is not nullable.
Signed-off-by: Johnny Lim <izeye@naver.com>
izeye
force-pushed
the
contracts-for-gauges
branch
from
July 17, 2025 15:19
42023ac to
b07ee6b
Compare
jonatan-ivanov
approved these changes
Jul 17, 2025
Member
|
I think this is definitely an improvement over what we have now but we might need to revert parts of this:
/cc @shakuzen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes to use
@Contractto improve nullability for gauges.