Closed

Description
I'm learning spring boot (using Spring-boot 2.1.3) while playing with REST API calls i found something interesting with HttpHeaders
object
Suppose if i have an HttpHeaders object with some values
HttpHeaders headers = new HttpHeaders();
headers.add("Connection", "keep-alive");
But now if i try to delete and add them again it throws NullPointerException
headers.entrySet().removeIf(entry -> entry.getKey().equals("Connection"));
headers.add("Connection", "keep-alive");
Error:
Caused by: java.lang.NullPointerException: null
at org.springframework.util.CollectionUtils$MultiValueMapAdapter.add(CollectionUtils.java:460) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.http.HttpHeaders.add(HttpHeaders.java:1559) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at com.demo.DemoMain.run(DemoMain.java:27) ~[main/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
... 5 common frames omitted