Skip to content

LinkedCaseInsensitiveMap does not track removals via keySet, entrySet, or values #22821

Closed
@ghost

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions