Description
From keycloak/keycloak#22299 (comment) -
Keycloak is creating an Operator per test class. Via cdi there is a single instance of each controller being constructed. When initAndRegisterEventSources is then called multiple times on these controllers if they maintain the same standalone depenent resource instance, the subsequent calls fail with an NPE:
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because "m" is null
at java.base/java.util.HashMap.putMapEntries(HashMap.java:495)
at java.base/java.util.HashMap.putAll(HashMap.java:783)
at io.javaoperatorsdk.operator.processing.event.source.informer.InformerManager.addIndexers(InformerManager.java:196)
at io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource.setConfigurationService(InformerEventSource.java:355)
at io.javaoperatorsdk.operator.processing.event.EventSourceManager.registerEventSource(EventSourceManager.java:160)
... 71 more
See https://github.com/keycloak/keycloak/actions/runs/5809929842/job/15750155150#step:8:10297
This does not seem to affect dependent resources that are registered via annotations.
The cause is nulling out the indexerBuffer
If this should be called multiple times, it should be re-initialized instead.
For now the keycloak pr keycloak/keycloak#22299 is working around this by creating a new depedent resource instance each time prepareEventSources is called. Does that seem ok for now, or should we make sure new instances of the Reconcilers are created for each test?