-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Incomplete nullness specification (@NullMarked
)
#1826
Comments
Sorry about that. I had contributed the nullness annotations, but I didn't follow through on updating the Javadoc before the release was published. The intent is that, if you want your Now, support for generics varies across tools. NullAway in particular has been doing some work in this area, both as part of their ongoing work on JSpecify and in response to requests from others, including Spring recently. If you find that it can't handle the scenario here, the NullAway maintainers would be interested to hear about it. (There is a definite chicken-and-egg problem with libraries that want to use advanced nullness annotations and tools that want to support them. We're getting at least a bit of a positive feedback loop in place through (among other things) the work that the Kotlin folks have done, but it's still early days.) |
I confirmed that the change I had in mind does not help with the NullAway error:
|
Oh, but I should try that with ...OK, I did that, and I still got the error. This seems similar to uber/NullAway#1075 (comment). Now,
That's here. And that does seem legitimate, given the background that the cache loader can return ...although... can it return |
Once I remove (None of this takes away from the fact that this upgrade is more painful as a result of the annotations and that I should get together better docs.) [*] I passed
|
Can you try that change @joschi? |
Our `CacheLoader` never returns `null`. When we upgrade to Caffeine 3.2.0 (dropwizard#9792), we'll have to either: - Declare that we're implementing a `CacheLoader<..., @nullable Class<?>>`, in which case we can keep `@Nullable` in the return type. - Continue to declare that we're implementing a `CacheLoader<..., Class<?>>`, in which case we'll need to remove `@Nullable` from the return type. See ben-manes/caffeine#1826.
Our `CacheLoader` never returns `null`. When we upgrade to Caffeine 3.2.0 (#9792), we'll have to either: - Declare that we're implementing a `CacheLoader<..., @nullable Class<?>>`, in which case we can keep `@Nullable` in the return type. - Continue to declare that we're implementing a `CacheLoader<..., Class<?>>`, in which case we'll need to remove `@Nullable` from the return type. See ben-manes/caffeine#1826.
Our `CacheLoader` never returns `null`. When we upgrade to Caffeine 3.2.0 (#9792), we'll have to either: - Declare that we're implementing a `CacheLoader<..., @nullable Class<?>>`, in which case we can keep `@Nullable` in the return type. - Continue to declare that we're implementing a `CacheLoader<..., Class<?>>`, in which case we'll need to remove `@Nullable` from the return type. See ben-manes/caffeine#1826.
Thanks for looking into this issue so quickly! I opted to use the PR you've opened (dropwizard/dropwizard#9806) and remove the |
We're experiencing extensive backwards compatibility issues as a result of 2542ca8. Even refactoring to use private static final class DummyLoader implements CacheLoader<String, @Nullable Integer> {
private DummyLoader() {}
@Override
public @Nullable Integer load(@NotNull String key) {
return null;
}
} yields
but maybe I need to set some Was this release meant to be this breaking? |
I think you’d need to raise this with NullAway (@msridhar) as an analysis issue. |
Yes, please raise an issue on the NullAway repo and we will take a look. |
The changes in commit 2542ca8 introduce JSpecify and specifically the
@NullMarked
annotation in Caffeine:Unfortunately the nullness specifications don't seem to be backward-compatible or some of the Javadoc is now outdated.
Example
While
CacheLoader
has the@NullMarked
annotation,CacheLoader#load(K)
doesn't have any additional@Nullable
annotation meaning that it cannot returnnull
.But the Javadoc for this method says:
Assuming there shouldn't be a breaking change in the API in a minor version, the method signature should be changed to match its documentation:
There are also other methods affected, but this is the one I ran into problems with. 😓
With tools such as NullAway already supporting and verifying the JSpecify annotations, this can lead to some issues with downstream projects such as Dropwizard.
dropwizard/dropwizard#9792
The text was updated successfully, but these errors were encountered: