Skip to content

Commit 71f40f2

Browse files
committed
Merge branch '6.3.x'
Use explicit types instead of var Closes gh-155537
2 parents c3e010f + 3b8cdc3 commit 71f40f2

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,15 @@ else if (authenticationProviders.size() > 1) {
7676
+ "using the DSL.", authenticationProviders.size(), beanNames));
7777
return;
7878
}
79-
var authenticationProvider = authenticationProviders.get(0).getBean();
80-
var authenticationProviderBeanName = authenticationProviders.get(0).getName();
79+
AuthenticationProvider authenticationProvider = authenticationProviders.get(0).getBean();
80+
String authenticationProviderBeanName = authenticationProviders.get(0).getName();
8181

8282
auth.authenticationProvider(authenticationProvider);
8383
this.logger.info(LogMessage.format(
8484
"Global AuthenticationManager configured with AuthenticationProvider bean with name %s",
8585
authenticationProviderBeanName));
8686
}
8787

88-
/**
89-
* @return a bean of the requested class if there's just a single registered
90-
* component, null otherwise.
91-
*/
92-
private <T> T getBeanOrNull(Class<T> type) {
93-
String[] beanNames = InitializeAuthenticationProviderBeanManagerConfigurer.this.context
94-
.getBeanNamesForType(type);
95-
if (beanNames.length != 1) {
96-
return null;
97-
}
98-
return InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanNames[0], type);
99-
}
100-
10188
/**
10289
* @return a list of beans of the requested class, along with their names. If
10390
* there are no registered beans of that type, the list is empty.

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeUserDetailsBeanManagerConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ else if (userDetailsServices.size() > 1) {
8989
beanNames));
9090
return;
9191
}
92-
var userDetailsService = userDetailsServices.get(0).getBean();
93-
var userDetailsServiceBeanName = userDetailsServices.get(0).getName();
92+
UserDetailsService userDetailsService = userDetailsServices.get(0).getBean();
93+
String userDetailsServiceBeanName = userDetailsServices.get(0).getName();
9494
PasswordEncoder passwordEncoder = getBeanOrNull(PasswordEncoder.class);
9595
UserDetailsPasswordService passwordManager = getBeanOrNull(UserDetailsPasswordService.class);
9696
CompromisedPasswordChecker passwordChecker = getBeanOrNull(CompromisedPasswordChecker.class);

config/src/test/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessorTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.junit.jupiter.api.Test;
2222
import org.junit.jupiter.api.extension.ExtendWith;
23+
import org.mockito.MockedStatic;
2324
import org.mockito.Mockito;
2425

2526
import org.springframework.aop.framework.ProxyFactory;
@@ -141,7 +142,7 @@ public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() {
141142

142143
@Test
143144
void postProcessWhenObjectIsCgLibProxyAndInNativeImageThenUseExistingBean() {
144-
try (var detector = Mockito.mockStatic(NativeDetector.class)) {
145+
try (MockedStatic<NativeDetector> detector = Mockito.mockStatic(NativeDetector.class)) {
145146
given(NativeDetector.inNativeImage()).willReturn(true);
146147

147148
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());
@@ -158,7 +159,7 @@ void postProcessWhenObjectIsCgLibProxyAndInNativeImageThenUseExistingBean() {
158159

159160
@Test
160161
void postProcessWhenObjectIsCgLibProxyAndInNativeImageAndBeanDoesNotExistsThenIllegalStateException() {
161-
try (var detector = Mockito.mockStatic(NativeDetector.class)) {
162+
try (MockedStatic<NativeDetector> detector = Mockito.mockStatic(NativeDetector.class)) {
162163
given(NativeDetector.inNativeImage()).willReturn(true);
163164

164165
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());

ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public void testRoleNamesStartWithDefaultRolePrefix() {
267267

268268
@Test
269269
public void testRoleNamesStartWithCustomRolePrefix() {
270-
var customPrefix = "GROUP_";
270+
String customPrefix = "GROUP_";
271271
this.mgr.setRolePrefix(customPrefix);
272272

273273
this.mgr.setUsernameMapper(new DefaultLdapUsernameToDnMapper("ou=people", "uid"));

0 commit comments

Comments
 (0)