Skip to content

MessageHeaderAccessor doesn't remove headers if they are null [SPR-14468] #19037

Closed
@spring-projects-issues

Description

@spring-projects-issues

Artem Bilan opened SPR-14468 and commented

The test-case to reproduce:

@Test
public void testRemoveEvenIfNull() {
	Message<?> message = new GenericMessage<>("payload", Collections.singletonMap("foo", null));
	MessageHeaderAccessor accessor = new MessageHeaderAccessor(message);
	accessor.removeHeader("foo");
	Map<String, Object> headers = accessor.toMap();
	assertFalse(headers.containsKey("foo"));
}

The workaround is only to extract a target Map and remove from there, and build a new Message.

But that doesn't help for Spring Integration's HeaderFilter to work properly.


Affects: 4.2.7, 4.3.1

Backported to: 4.2.8

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions