Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Test framework registry throws NPE with cleanup if there's a failure during init #46162

@stianst

Description

@stianst

If the test wasn't started successfully, for example Keycloak server fails to start, there's this NPE thrown by the registry:

java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "testInstance" is null

	at org.keycloak.testframework.injection.Registry.executeSetup(Registry.java:267)
	at org.keycloak.testframework.injection.Registry.afterAll(Registry.java:286)
	at org.keycloak.testframework.KeycloakIntegrationTestExtension.afterAll(KeycloakIntegrationTestExtension.java:44)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

This is caused by lack of checking if currentTestInstance is not set in afterAll, and it won't be set unless the test was successfully initialised.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions