Fix ColdBox 8 compatibility by replacing deprecated processState with announce #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the ColdBox 8 incompatibility issue where calls to
interceptorService.processState()throw exceptions due to method deprecation.Problem
In ColdBox 8, the
processState()method was deprecated in favor of the newannounce()method for triggering interception events. This caused Hyper to throw exceptions when used with ColdBox 8:// This throws an exception in ColdBox 8 variables.interceptorService.processState("onHyperRequest", { "request" : this });Solution
Implemented a backward-compatible solution that automatically detects the available method and uses the appropriate one:
announce()methodprocessState()methodChanges Made
Added
announceInterception()helper method that provides version-agnostic interceptor announcements:private void function announceInterception( required string interceptionPoint, struct data = {} ) { if ( structKeyExists( variables.interceptorService, "announce" ) ) { variables.interceptorService.announce( arguments.interceptionPoint, arguments.data ); } else { variables.interceptorService.processState( arguments.interceptionPoint, arguments.data ); } }Updated default interceptorService mock to include both methods for testing scenarios
Replaced all direct
processState()calls with the new helper method in:send()method (onHyperRequest event)debug()method (onHyperRequest event)Benefits
✅ Full backward compatibility - Works seamlessly with both ColdBox 7 and ColdBox 8+
✅ No breaking changes - Existing code continues to work without modification
✅ Future-proof - Adopts the preferred ColdBox 8 approach while maintaining legacy support
✅ Minimal changes - Surgical fix that only touches the necessary code paths
Testing
The fix maintains all existing interceptor functionality:
onHyperRequestinterceptors continue to work as expectedonHyperResponseinterceptors continue to work as expectedThis ensures Hyper can be used with any ColdBox version without compatibility concerns.
Original prompt
Fixes #56
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.