Skip to content

Commit d18ff25

Browse files
committed
Use SecurityContextHolderStrategy for NullSecurityContextRepository
Issue gh-11060
1 parent 05b788d commit d18ff25

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

web/src/main/java/org/springframework/security/web/context/NullSecurityContextRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -22,6 +22,7 @@
2222
import org.springframework.security.core.context.SecurityContext;
2323
import org.springframework.security.core.context.SecurityContextHolder;
2424
import org.springframework.security.core.context.SecurityContextHolderStrategy;
25+
import org.springframework.util.Assert;
2526

2627
/**
2728
* @author Luke Taylor
@@ -53,6 +54,7 @@ public void saveContext(SecurityContext context, HttpServletRequest request, Htt
5354
* @since 5.8
5455
*/
5556
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy strategy) {
57+
Assert.notNull(this.securityContextHolderStrategy, "securityContextHolderStrategy cannot be null");
5658
this.securityContextHolderStrategy = strategy;
5759
}
5860

0 commit comments

Comments
 (0)