Skip to content

Commit 7809399

Browse files
committed
fix: do not fail spring context creation when SpringSecurityExceptionHandler are not provided
1 parent 1809c0d commit 7809399

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-security-exception-handler/src/main/java/dev/clutcher/security/filter/SpringSecurityExceptionFilter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ public class SpringSecurityExceptionFilter extends OncePerRequestFilter {
2020
private List<SpringSecurityExceptionHandler> handlers;
2121

2222
public SpringSecurityExceptionFilter(List<SpringSecurityExceptionHandler> handlers) {
23+
// Used to manually create Spring Bean in Configuration
2324
this.handlers = new ArrayList<>(handlers);
2425
}
2526

2627
public SpringSecurityExceptionFilter() {
28+
// ! Default constructor is used by [[SecurityConfigurer]] to create new instances
2729
this.handlers = new ArrayList<>();
2830
}
2931

30-
@Autowired
32+
@Autowired(required = false)
3133
public void setHandlers(List<SpringSecurityExceptionHandler> handlers) {
34+
// ! @Autowired setter is used by [[SecurityConfigurerAdapter#postProcess]] to inject beans after creating
35+
// ! instance with the default constructor.
3236
this.handlers = new ArrayList<>(handlers);
3337
}
3438

0 commit comments

Comments
 (0)