Skip to content

engine-java: make the 'a JavaDelegate must NOT be a @Component' rule observable (#7223) - #7272

Open
NicoleNG18 wants to merge 1 commit into
eclipse-dirigible:masterfrom
NicoleNG18:issue-7223-enforce-delegate-not-component
Open

engine-java: make the 'a JavaDelegate must NOT be a @Component' rule observable (#7223)#7272
NicoleNG18 wants to merge 1 commit into
eclipse-dirigible:masterfrom
NicoleNG18:issue-7223-enforce-delegate-not-component

Conversation

@NicoleNG18

Copy link
Copy Markdown
Contributor

Cause

The rule that a BPMN JavaDelegate must not be annotated @Component was documented in four places (.claude/docs/client-java.md, engine-java/CLAUDE.md, the two assistant guides, and a scaffold stub comment) but nothing in the runtime enforced, warned about, or even noticed a violation. After #7189 the old symptom - injected fields reading null at runtime - is gone, because both the container-built singleton and the Flowable-built instance are now wired. So a developer had no signal at all: an annotated delegate silently becomes a registered bean nobody runs, and a stray candidate for every List<JavaDelegate> injection.

Change

  • ComponentContainer.createUnmanaged now emits one LOGGER.warn naming the class and the rule when the delegate type is a bean, making the violation observable at the moment it happens. A unit test asserts the warn fires.
  • ComponentContainerUnmanagedTest.an_unsatisfied_dependency_is_refused_and_is_not_a_rebuild_error built the container from no classes, so its wiringErrors().isEmpty() assertion was trivially true whatever createUnmanaged did; it now builds with a registered bean and a delegate needing an absent type, so the "not a rebuild error" half is load-bearing.
  • DirigibleJavaCallDelegate: the fallback instantiation error no longer advises "or declare the collaborators it injects as @component" - that branch is reached only when the class declares no injection point, so the advice can never apply; reverted to the plain message the camel sibling (DirigibleJavaInvokerImpl) already uses. Its class javadoc now lists @PostConstruct alongside constructor and @Inject field as an injection point (all three are counted by declaresInjectionPoint / ClientBeanFactory).
  • ComponentContainer / JavaLoader javadoc no longer list @Extension among the consumers - the SDK has no such annotation (sdk/component/ holds only Beans, Component, Inject, Repository).

The documented rule itself is correct and unchanged; this PR only makes it observable and corrects the stale text from #7189.

Verification

  • mvn formatter:validate after wiping the formatter cache - BUILD SUCCESS.
  • engine-java + engine-bpm-flowable unit suites - green (129 tests, including the new warn test in ComponentContainerUnmanagedTest).
  • JavaDelegateInjectionIT - green (3/3); confirms both delegate paths still wire and the unsatisfiable-dependency step still dead-letters rather than failing the deployment.
  • Release-profile javadoc build - green on both changed modules.

Not run: the full IT suite (unchanged runtime behaviour beyond a log line and text; CI covers it).

Fixes #7223

…observable (eclipse-dirigible#7223)

The rule that a BPMN JavaDelegate must not be annotated @component was documented
in several places but nothing in the runtime enforced, warned about, or even
noticed a violation - and after eclipse-dirigible#7189 the old symptom (injected fields reading
null at runtime) is gone, because both the container-built singleton and the
Flowable-built instance are now wired. So a developer had no signal at all: an
annotated delegate silently becomes a registered bean nobody runs, a stray
candidate for every List<JavaDelegate> injection.

Change:
- ComponentContainer.createUnmanaged now emits one LOGGER.warn naming the class
  and the rule when the delegate type is a bean, making the violation observable
  at the moment it happens. A unit test asserts the warn fires.
- ComponentContainerUnmanagedTest.an_unsatisfied_dependency_is_refused_and_is_not_a_rebuild_error
  built the container from NO classes, so its wiringErrors().isEmpty() assertion
  was trivially true; it now builds with a registered bean and a delegate needing
  an absent type, so the "not a rebuild error" half is load-bearing.
- DirigibleJavaCallDelegate: the fallback instantiation error no longer advises
  "declare the collaborators it injects as @component" - that branch is reached
  only when the class declares no injection point, so the advice can never apply;
  reverted to the plain message the camel sibling (DirigibleJavaInvokerImpl)
  already uses. Its class javadoc now lists @PostConstruct alongside constructor
  and @Inject field as an injection point (both are counted).
- ComponentContainer / JavaLoader javadoc no longer list @extension among the
  consumers - the SDK has no such annotation.

Verified: mvn formatter:validate (BUILD SUCCESS, cache wiped); engine-java +
engine-bpm-flowable unit suites green (129 tests, incl. the new warn test);
JavaDelegateInjectionIT green (3/3); release-profile javadoc build green on both
modules.

Fixes eclipse-dirigible#7223

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 this pull request may close these issues.

engine-java: 'a JavaDelegate must NOT be a @Component' is documented four times and enforced nowhere - and the symptom that used to reveal it is gone

1 participant