Skip to content

Commit 6e3f974

Browse files
committed
HttpHeaders.writableHttpHeaders properly handles HttpHeaders.EMPTY
Issue: SPR-17633
1 parent 1faeeae commit 6e3f974

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1694,11 +1694,15 @@ public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
16941694
}
16951695

16961696
/**
1697-
* Return a {@code HttpHeaders} object that can read and written to.
1697+
* Return a {@code HttpHeaders} object that can be read and written to.
1698+
* @since 5.1.1
16981699
*/
16991700
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {
17001701
Assert.notNull(headers, "HttpHeaders must not be null");
1701-
if (headers instanceof ReadOnlyHttpHeaders) {
1702+
if (headers == EMPTY) {
1703+
return new HttpHeaders();
1704+
}
1705+
else if (headers instanceof ReadOnlyHttpHeaders) {
17021706
return new HttpHeaders(headers.headers);
17031707
}
17041708
else {

0 commit comments

Comments
 (0)