I have following classes.
public abstract class _ApiController {
@EventListener
void onApplicationEvent(final ReactiveWebServerInitializedEvent event) {
webServer = event.getWebServer(); // `this`: SomeApiController$$SPRINGCGLIB@... instance.
}
WebServer webServer;
}
@Validated // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< seems make a CGLIB proxy
@RestController
class SomeApiController
extends _ApiController {
@GetMapping(path = "/")
Mono<Void> read(final ServerHttpResponse response) {
// `this` is not the SomeApiController$$SPRINGCGLIB@...
// super.webServer is null
}
}
When the onApplicationEvent
method invoked, the this
debug instance is a proxy instance
and, when the read
method invoked, the proxy’s gone,
and the webServer
field is null
.
What is the right solution for this?