Non-deterministic NPE on rate-limiting code -> fails smoke test build check ocasionally
This is sometimes observed during smoke-test execution:
ERROR [2020-11-29 01:16:35,200] es.moki.ratelimij.dropwizard.filter.RateLimit429EnforcerFilter: Error occurred checking rate-limit. Assuming under limit
! java.lang.NullPointerException: null
! at es.moki.ratelimij.dropwizard.filter.RateLimit429EnforcerFilter.filter(RateLimit429EnforcerFilter.java:54)
! at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:108)
! at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:44)
! at org.glassfish.jersey.process.internal.Stages.process(Stages.java:173)
! at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:247)
! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
It turns out the above stack trace is a complete red-herring and is not failing the tests at all!
The problem is involving test data and ordering of which tests run. Some tests are missing a data setup and if those are run first, they fail. If those tests are run after other tests set up the required database data, then they will pass.
It is hard to make sense of this scenario, we do have this code (in DropWizardServerExtension) to delete data between tests:
@Override
public void beforeEach(final ExtensionContext context) throws Exception {
final URL cleanupFileUrl = getClass().getClassLoader().getResource("db-cleanup.sql");
if (cleanupFileUrl != null) {
final String cleanupSql = Files.readString(Path.of(cleanupFileUrl.toURI()));
jdbi.withHandle(handle -> handle.execute(cleanupSql));
}
}
I noticed there has not been much activity on this issue. Please check this issue and close it if it no longer applies. Otherwise to help move this issue move forward, please add a comment summarizing any further actions that need to be taken in order to resolve this issue.
@DanVanAtta Does this issue still occur sometimes during smoke-test execution?