Skip to content

Repeated initialization of a standalone dependent resource fails #2010

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

Closed
shawkins opened this issue Aug 9, 2023 · 2 comments · Fixed by #2026
Closed

Repeated initialization of a standalone dependent resource fails #2010

shawkins opened this issue Aug 9, 2023 · 2 comments · Fixed by #2026
Assignees

Comments

@shawkins
Copy link
Collaborator

shawkins commented Aug 9, 2023

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?

@shawkins
Copy link
Collaborator Author

I'm also seeing this with non-stanalone sources after some additional test changes. I'll link to the workaround in the pr once it is opened. The basic problem is that we're manually re-creating the operator per each test class, which may not be a good idea.

@csviri csviri linked a pull request Aug 23, 2023 that will close this issue
@csviri
Copy link
Collaborator

csviri commented Aug 23, 2023

I made a quick fix in the sdk, was not really designed for this, but should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants