Skip to content

Assert non-null arguments in DefaultServerRequestBuilder methods #30046

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

Closed
wants to merge 6 commits into from

Conversation

srivatsa-cfp
Copy link
Contributor

- Add Null check for Http Header Name , https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/HttpHeaders.html#add(java.lang.String,java.lang.String). As per doc only header values can be nullable
- Add Null check for Http HeaderConsumer
- Add Null check for Cookie Name 
- Add Null check for CookierConsumer
…er-1

fix(src): add validation for http headers and cookie
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 27, 2023
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Feb 28, 2023
@sbrannen sbrannen changed the title fix(src): add validation for http headers and cookie Assert non-null arguments in DefaultServerRequestBuilder methods Feb 28, 2023
@sbrannen
Copy link
Member

Note that @NonNullApi is specified at the package level in package-info.java. Thus, none of those arguments are allowed to be null.

However, we do have inconsistent state in both DefaultServerRequestBuilder variants with regard to explicit non-null assertions.

If we introduce additional non-null assertions for those arguments, we would want to do that consistently for all such methods and consistently across both DefaultServerRequestBuilder variants (MVC and WebFlux).

@srivatsa-cfp
Copy link
Contributor Author

@sbrannen Yes specification says it to be not null, but no implementation might cause an inconsistent. I will verify it to be consistent across MVC & WebFlux. Do you any further concerns on non-null assertions?

Add Null check for Http Header Name , https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/HttpHeaders.html#add(java.lang.String,java.lang.String). As per doc only header values can be nullable
Add Null check for Http HeaderConsumer
Add Null check for Cookie Name
Add Null check for CookierConsumer
…er-Webflux

Assert non-null arguments in DefaultServerRequestBuilder methods
@srivatsa-cfp
Copy link
Contributor Author

Added the assert non-null checks in DefaultServerRequestBuilder in spring-webflux

@sbrannen sbrannen marked this pull request as draft March 1, 2023 12:29
@sbrannen
Copy link
Member

sbrannen commented Mar 1, 2023

@srivatsa-cfp,

We may decide to introduce non-null assertions in those builder methods, or we may decide to remove all of the non-null assertions and to rely on null-safety annotations instead.

So, please hold off on making further changes until the team has reached a decision on this topic.

@poutsma poutsma self-assigned this Mar 7, 2023
@poutsma
Copy link
Contributor

poutsma commented Mar 7, 2023

@srivatsa-cfp We have decided that null assertions would be useful to have in builder methods, so please continue with your PR and let me know when it's done.

@srivatsa-cfp
Copy link
Contributor Author

@poutsma Added all the required null assertions in DefaultSertverRequestBuilder across webflux and web-mvc.

@poutsma poutsma closed this in d8fbd35 Mar 8, 2023
poutsma added a commit that referenced this pull request Mar 8, 2023
* gh-30046:
  Add non-null assertions in DefaultServerRequestBuilder
@poutsma
Copy link
Contributor

poutsma commented Mar 8, 2023

Merged, thanks for creating a PR!

@poutsma poutsma added this to the 6.0.7 milestone Mar 8, 2023
@poutsma poutsma removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants