-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Kazuki Shimizu opened SPR-12792 and commented
If specified null value as method argument of HeadersBuilder#headers, NullPointerException occur.
I want to change this behavior as follows:
- Ignore a null value(the same as
HttpEntityconstructor) - Check a null value using
Assert#notNullmethod
I want to apply a first idea(ignore a null value).
e.g)
private ResponseEntity<String> createResponseEntity(
String body,
HttpHeaders customHeaders) {
return ResponseEntity
.ok()
.headers(customHeaders)
.header("X-Track", UUID.randomUUID().toString())
.body(body);
}
// ...
@Test
public void test() {
System.out.println(createResponseEntity("test", new HttpHeaders()));
System.out.println(createResponseEntity("test", null));
}<200 OK,test,{X-Track=[2a7ed446-c805-42a6-ada7-982ff9d2b6d7]}>
java.lang.NullPointerException
at org.springframework.util.LinkedCaseInsensitiveMap.putAll(LinkedCaseInsensitiveMap.java:101)
at org.springframework.http.HttpHeaders.putAll(HttpHeaders.java:907)
at org.springframework.http.ResponseEntity$DefaultBuilder.headers(ResponseEntity.java:384)
at org.springframework.http.ResponseEntity$DefaultBuilder.headers(ResponseEntity.java:364)
at ResponseEntityTest.createResponseEntity(ResponseEntityTest.java:33)
at ResponseEntityTest.test(ResponseEntityTest.java:17)
...
Affects: 4.1.5
Referenced from: pull request #753
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement