MessageHeaderAccessor properly removes header even in case of null value

Issue: SPR-14468
(cherry picked from commit b166358)
This commit is contained in:
Juergen Hoeller
2016-07-15 00:15:46 +02:00
parent da59b4da9b
commit 4ea5f070a4
2 changed files with 31 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -306,12 +306,17 @@ public class MessageHeaderAccessor {
throw new IllegalArgumentException("'" + name + "' header is read-only");
}
verifyType(name, value);
if (!ObjectUtils.nullSafeEquals(value, getHeader(name))) {
this.modified = true;
if (value != null) {
if (value != null) {
// Modify header if necessary
if (!ObjectUtils.nullSafeEquals(value, getHeader(name))) {
this.modified = true;
this.headers.getRawHeaders().put(name, value);
}
else {
}
else {
// Remove header if available
if (this.headers.containsKey(name)) {
this.modified = true;
this.headers.getRawHeaders().remove(name);
}
}