Skip to content

Removing a key from HttpHeaders' key set leaves it in an inconsistent state #23633

Closed
@wilkinsona

Description

@wilkinsona

Affects: 5.1.10 snapshots

The problem is illustrated by the following test:

package example;

import java.util.Arrays;

import org.junit.Test;

import org.springframework.http.HttpHeaders;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;

public class HttpHeadersTests {

	@Test
	public void removeFromKeySet() {
		HttpHeaders httpHeaders = new HttpHeaders();
		httpHeaders.set("Alpha", "apple");
		httpHeaders.set("Bravo", "banana");
		httpHeaders.keySet().remove("Alpha");
		assertThat(httpHeaders).containsOnly(entry("Bravo", Arrays.asList("banana")));
		assertThat(httpHeaders).doesNotContainKey("Alpha");
	}

}

The first assertion passes but the second fails:

java.lang.AssertionError: 
Expecting:
  <{"Bravo"=["banana"]}>
not to contain key:
  <"Alpha">
	at example.HttpHeadersTests.removeFromKeySet(HttpHeadersTests.java:21)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions