Skip to content

COLDBOX-1469 A disabled nested module breaks its parent, removeChildInjector() throws, and a child injector shutdown stops the application's caches - #730

Open
homestar9 wants to merge 3 commits into
ColdBox:developmentfrom
homestar9:fix/module-injector-bugs
Open

homestar9 wants to merge 3 commits into
ColdBox:developmentfrom
homestar9:fix/module-injector-bugs

Conversation

@homestar9

Copy link
Copy Markdown
Contributor

Description

Three small bugs in the module and child injector code, fixed together because they sit next to each other.

A disabled nested module stops its parent from activating. ModuleService.registerModule() added a nested module to the parent's childModules list before registering it. A module with this.disabled = true is never registered but stayed on the list, so activating the parent failed with Cannot activate module (disabledChild) as it has not been registered. A nested module is now added to the list only when it registered, or when another parent already registered a module with that name.

Injector.removeChildInjector() throws when the child is not found. It returned falase instead of false, which is an undefined variable.

Shutting down a child injector shuts down every cache in the application. Injector.shutdown() shut down CacheBox whenever CacheBox was linked. In a ColdBox application the application owns CacheBox and shuts it down in LoaderService.processShutdown(). shutdown() already skips LogBox and the executors when ColdBox is linked; CacheBox now gets the same check. This applies to every ColdBox-linked injector, including the root. That is intended: in a ColdBox application no injector should shut down the application's caches.

Jira Issues

https://ortussolutions.atlassian.net/browse/COLDBOX-1469

Part of https://ortussolutions.atlassian.net/browse/COLDBOX-1478

Type of change

  • Bug Fix

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Tests

  • tests/specs/web/services/ModuleServiceInceptionTest.cfc (new): a parent with a disabled nested module activates and does not list it. Test modules in tests/resources/inceptionfixtures/.
  • tests/specs/ioc/InjectorTest.cfc: removeChildInjector() returns false for an unknown name, and shutting down a ColdBox-linked injector leaves CacheBox running.

The 3 new specs fail on the 8.3.0 code. With the fix, every spec in the changed files passes on BoxLang (CFML compat), Lucee 5 and Adobe 2025.

…oveChildInjector() throws, and a child injector shutdown stops the application's caches

- A disabled nested (inception) module broke its parent's activation.
  childModules was appended before registration was attempted, so a child
  with this.disabled = true produced IllegalModuleState in the activation
  cascade. Only children that actually registered are tracked now.

- Injector.removeChildInjector() returned a typo'd variable name (falase)
  instead of false when the child was not found, raising an undefined
  variable error.

- Injector.shutdown() shut down the application's CacheBox whenever a
  ColdBox-linked child injector was shut down, unregistering every cache
  for the whole application. The application owns that lifecycle via
  LoaderService.processShutdown(). shutdown() already guarded LogBox and
  the executors with !isColdBoxLinked(); CacheBox now has the same guard.

Each fix has a spec that fails without it.
@homestar9
homestar9 marked this pull request as ready for review October 27, 2026 22:25
…; prove a disabled dependency still fails

Only a disabled nested module is now left off its parent's childModules list. A child whose name was already in the module registry (for example a top-level copy) stays on the list, so the parent's activation still reaches it as before. New specs: a parent that lists its disabled nested child in this.dependencies still throws IllegalModuleState, and a nested child whose name is already known stays on the parent's list.
…throws IllegalModuleState for an unregistered module
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.

1 participant