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

Revisit nullability annotations towards GA [SPR-15756] #20311

Closed
spring-projects-issues opened this issue Jul 10, 2017 · 4 comments
Closed

Revisit nullability annotations towards GA [SPR-15756] #20311

spring-projects-issues opened this issue Jul 10, 2017 · 4 comments
Assignees
Labels
in: core type: task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jul 10, 2017

Rob Winch opened SPR-15756 and commented

Currently @NonNullApi can be specified at a package level only. It would be nice if there were a way to do this at a type level as well. This is of interest to users migrating to using the annotated approach to handling null values who haven't converted their entire code base appropriately and want to avoid warnings.

For example, consider a user who wants to implement WebSessionManager. If they create an implementation, like this:

public class MyWebSessionManager implements WebSessionManager {
	@Override
	public Mono<WebSession> getSession(ServerWebExchange serverWebExchange) {
		...
	}
}

The user is given the warning:

Not annotated method overrides method annotated with @NonNullApi....

To properly resolve this warning, the user would currently need to place @NonNullApi at the package level. However, any other APIs within the package would also be impacted. It would be nice if the @NonNullApi (or similar annotation) could be placed on the type level.

Obviously in the long run, it would be good for the user to expand through the entire package. However, there is some effort involved in migrating so something supporting the type level would be valuable.


Affects: 5.0 RC2

Reference URL: https://github.com/Kotlin/KEEP/blob/jsr-305/proposals/jsr-305-custom-nullability-qualifiers.md

Issue Links:

  • #20496 Support null-safety at generics, varargs and array elements level ("is depended on by")
  • #20424 Fix overridden methods nullability
  • #20099 Introduce null-safety of Spring Framework API
  • #20276 Extend null-safety to field level
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 20, 2017

Juergen Hoeller commented

In the above case, wouldn't an @Nullable declaration on the overridden method solve the problem, along the lines of #20424?

In any case, let's use this opportunity to revisit @NonNullApi overall, double-checking whether we're happy with its semantics.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 6, 2017

Sébastien Deleuze commented

Notice than JSR 305 meta-annotations should be applied to generic type arguments as well with Kotlin 1.0.5, which was the last known issue I am aware of.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 11, 2017

Sébastien Deleuze commented

Rob Winch We plan to introduce a Spring @NonNull annotation, similar to @Nullable with the opposite semantic. These both annotations should allow to deal with #20496 as well as the progressive nullability use case that you described.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 15, 2017

Sébastien Deleuze commented

Resolved via this commit, see the commit message for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: task
Projects
None yet
Development

No branches or pull requests

2 participants