-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Broken OAuth2AuthorizationRequestRedirectFilter constructor tests #18507
Description
There are some tests that pass in null (with no type) into OAuth2AuthorizationRequestRedirectFilter constructor expecting an IllegalArgumentException. The tests pass not because the constructor throws an IllegalArgumentException, but because there are multiple constructors and the proper constructor cannot be selected without type information.
An example is found at constructorWhenClientRegistrationRepositoryIsNullThenThrowIllegalArgumentException. If you look at the actual stacktrace, you can see it is reflection code and not the constructor throwing the IllegalArgumentException.
wrong number of arguments
java.lang.IllegalArgumentException: wrong number of arguments
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilterTests.constructorWhenClientRegistrationRepositoryIsNullThenThrowIllegalArgumentException(OAuth2AuthorizationRequestRedirectFilterTests.java:92)
We can remove the unnecessary reflection and include the type information to ensure the constructor is being checked properly
NOTE: This is important in order to be able to run with JDK 25 because the exception type changes