-
Notifications
You must be signed in to change notification settings - Fork 41.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.ClassCastException when using default management security with WebFlux and health probes enabled #44052
Comments
Hi @edudar-chwy. 👋 Thank you for creating this detailed issue. I'm running into this problem as well and had to downgrade to 3.3. Do you perhaps have a workaround for this regression? |
Thanks for the detailed analysis, @edudar-chwy. Can you please take a step back and share some more information about your application's configuration and also the stack trace of the I've managed to trigger the following failure:
It requires the use of |
Hi @wilkinsona Please find the attached minimal reproduction with logs and traces: Many thanks for taking a look at this 🙏 |
Thanks, @tim-08df33fc. I can see that you're using Boot's default management security which uses @edudar-chwy I'd still welcome some information about your setup so that we can be sure that any fix addresses your problem too. |
Thank you @wilkinsona . I've provided my own security configuration with a
|
@wilkinsona, the stacktrace is pretty much identical to what @tim-08df33fc posted:
We don't call |
Environment:
After upgrading to Spring Boot 3.4 from 3.3 I see an unexpected ClassCastException while calling /health endpoints on Kubernetes, specifically because this works locally as availability probes are not enabled unless in Kubernetes or CloudFoundry or explicitly in properties:
While tracing it down, I narrowed the change to #40962 and this commit when additionalPathsMappers were added to
WebEndpointDiscoverer
.HealthEndpointConfiguration
creates a bean of typeHealthEndpointGroups
namedhealthEndpointGroups
with the instance ofAutoConfiguredHealthEndpointGroups
that implementsHealthEndpointGroups, AdditionalPathsMapper
.At the same time,
AvailabilityProbesAutoConfiguration
creates a post-processor of typeAvailabilityProbesHealthEndpointGroupsPostProcessor
that, in turn, also creates a bean ofHealthEndpointGroups
but using an instance ofAvailabilityProbesHealthEndpointGroups
that implements onlyHealthEndpointGroups
but notAdditionalPathsMapper
.When
WebEndpointAutoConfiguration
createswebEndpointDiscoverer
it autowiresObjectProvider<AdditionalPathsMapper> additionalPathsMappers
and usesadditionalPathsMappers.orderedStream().toList()
but this calls hides the problem due to generics. CallingadditionalPathsMappers.getIfAvailable()
fails withBeansNotOfRequiredTypeException
which is correct.Digging deeper into
additionalPathsMappers.orderedStream()
, I seeDefaultListableBeanFactory.findAutowireCandidates()
tries to findcandidateNames
byAdditionalPathsMapper.class
and gets"healthEndpointGroups"
, but whenbeanfactory
gets a bean by that name, it isAvailabilityProbesHealthEndpointGroups
which does not implementAdditionalPathsMapper
. Because of generics, this issue is not showing up all the way untilDiscoveredWebEndpoint.getAdditionalPaths()
is called because if explicitly requiresAdditionalPathsMapper
but getsAvailabilityProbesHealthEndpointGroups
which is not.The text was updated successfully, but these errors were encountered: