File tree 1 file changed +11
-3
lines changed
spring-web/src/main/java/org/springframework/web
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
30
30
* Default implementation of {@link ErrorResponse.Builder}.
31
31
*
32
32
* @author Rossen Stoyanchev
33
+ * @author 海子 Yang
33
34
* @since 6.0
34
35
*/
35
36
final class DefaultErrorResponseBuilder implements ErrorResponse .Builder {
@@ -66,18 +67,25 @@ final class DefaultErrorResponseBuilder implements ErrorResponse.Builder {
66
67
67
68
@ Override
68
69
public ErrorResponse .Builder header (String headerName , String ... headerValues ) {
69
- this .headers = (this .headers != null ? this .headers : new HttpHeaders ());
70
70
for (String headerValue : headerValues ) {
71
- this . headers .add (headerName , headerValue );
71
+ httpHeaders () .add (headerName , headerValue );
72
72
}
73
73
return this ;
74
74
}
75
75
76
76
@ Override
77
77
public ErrorResponse .Builder headers (Consumer <HttpHeaders > headersConsumer ) {
78
+ headersConsumer .accept (httpHeaders ());
78
79
return this ;
79
80
}
80
81
82
+ private HttpHeaders httpHeaders () {
83
+ if (this .headers == null ) {
84
+ this .headers = new HttpHeaders ();
85
+ }
86
+ return this .headers ;
87
+ }
88
+
81
89
@ Override
82
90
public ErrorResponse .Builder type (URI type ) {
83
91
this .problemDetail .setType (type );
You can’t perform that action at this time.
0 commit comments