Skip to content

fix(engine): reinitialize stale engine in ProcessEngineExtension - #4070

Merged
javahippie merged 1 commit into
mainfrom
fix/engine-extension-stale-engine
Nov 7, 2026
Merged

javahippie merged 1 commit into
mainfrom
fix/engine-extension-stale-engine

Conversation

@javahippie

Copy link
Copy Markdown
Contributor

Fixes #4052

Problem

Several abstract test bases hold a static ProcessEngineExtension that all subclasses share
(AbstractUserOperationLogTest, AbstractDefinitionQueryTest, EmailTestCase, AbstractMetricsTest).
Tests like RuntimeServiceTest.testStartProcessInstanceByIdAfterReboot and
standalone.initialization.ProcessEnginesTest call ProcessEngines.destroy(), which closes the cached engine.

The next test class registers a new engine named default. The extension only checked the name, so it kept the
closed engine. That engine's job executor no longer has a registered engine and acquires nothing, so tests that
wait for the job executor time out (UserOperationLogJobTest, ProcessDefinitionQueryTest, AsyncEmailTaskTest,
TaskListenerTest, JobExecutorMetricsTest, ...). Whether this happens depends on class order, which is why the
nightly turned red after the runner image changed.

Fix

beforeEach and postProcessTestInstance now compare the registered engine by identity. Both are needed:
services are injected in postProcessTestInstance, before beforeEach runs.

Verification

Engine tests on H2 with junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$Random:

Runs Red
without fix 43 24
with fix 14 0

Minimal repro for seed 63865769: RedeploymentRegistrationTest, CaseDefinitionQueryTest, ProcessEnginesTest,
ErrorEventSubProcessTest, then ProcessDefinitionQueryTest fails. Green with the fix.

To reproduce:

./mvnw test -pl engine \
  -Djunit.jupiter.testclass.order.default='org.junit.jupiter.api.ClassOrderer$Random' \
  -Djunit.jupiter.execution.order.random.seed=63865769

A static extension shared by several test classes kept a closed
engine after ProcessEngines.destroy(). The next class registered a
new engine under the same name, so the name check passed and tests
used the closed engine. Its job executor acquired jobs for no engine,
which made job executor tests time out depending on class order.

Check the registered instance by identity in beforeEach and
postProcessTestInstance.

Fixes #4052
@github-actions github-actions Bot added lang:java Pull requests that update Java code scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI labels Nov 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

@javahippie
javahippie merged commit 77aa11b into main Nov 7, 2026
15 checks passed
kthoms pushed a commit that referenced this pull request Nov 8, 2026
@kthoms kthoms added this to the 2.2.2 milestone Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang:java Pull requests that update Java code scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly integration build fails on UserOperationLogJobTest since ubuntu-26.04

2 participants