Skip to content

Commit add1305

Browse files
committed
Re-add vararg options in WebHttpHandlerBuilder
WebHttpHandlerBuilder is low level not expected to appear frequently but they might be repeated more in tests (e.g. of WebFilter's). Issuse: SPR-15499
1 parent 459457e commit add1305

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.web.server.adapter;
1717

1818
import java.util.ArrayList;
19+
import java.util.Arrays;
1920
import java.util.List;
2021

2122
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -147,6 +148,17 @@ public static WebHttpHandlerBuilder applicationContext(ApplicationContext contex
147148
}
148149

149150

151+
/**
152+
* Add the given filter(s).
153+
* @param filters the filter(s) to add
154+
*/
155+
public WebHttpHandlerBuilder filter(WebFilter... filters) {
156+
if (!ObjectUtils.isEmpty(filters)) {
157+
this.filters.addAll(Arrays.asList(filters));
158+
}
159+
return this;
160+
}
161+
150162
/**
151163
* Add the given filters.
152164
* @param filters the filters to add
@@ -168,6 +180,17 @@ public WebHttpHandlerBuilder prependFilter(WebFilter filter) {
168180
return this;
169181
}
170182

183+
/**
184+
* Add the given exception handler(s).
185+
* @param handlers the exception handler(s)
186+
*/
187+
public WebHttpHandlerBuilder exceptionHandler(WebExceptionHandler... handlers) {
188+
if (!ObjectUtils.isEmpty(handlers)) {
189+
this.exceptionHandlers.addAll(Arrays.asList(handlers));
190+
}
191+
return this;
192+
}
193+
171194
/**
172195
* Add the given exception handlers.
173196
* @param handlers the exception handlers

0 commit comments

Comments
 (0)