Interception with `async` annotation causes InterceptorState Exception on Reinit

Description

If an interception in the app stack is marked with the async annotation, the first attempt to reinit the application will throw a java.util.ConcurrentModificationException within the loop of interceptors once the invokerAsync is called within the loop of interceptors

Stack Trace:

 

Code Frame from InterceptorState.cfc:

Activity

Show:

Luis MajanoMay 4, 2022 at 8:46 PM

Thanks for the push

 

I will be commuting something this afternoon

Jon ClausenMay 4, 2022 at 6:29 PM

Any word on when this will be patched in? What makes this a critical issue is that the preReinit interceptions in any code base will no longer fire because the error occurs before that interception is announced. The next request, even with a reinit, will not fire those interceptions, because it goes through the Bootstrap ( since the framework is in an incomplete state ).

In short this is turning out to be a bigger issue than I thought it was, because Java singletons are being orphaned and shutdown routines are not firing.

Luis MajanoApril 22, 2022 at 10:04 PM

After checking the lucee code, they don’t use synchronized maps either. So moving to an ordered struct via structNew( 'ordered' ) is the same. So my only choice is to synchronize the map

Luis MajanoApril 22, 2022 at 10:01 PM

It wasn’t for the performance gain, it was to have a linked struct which didn’t exist in cfml. It has to be a an ordered map. NOw, I can synchronize it, or use the CFML native ordered struct, but I am not sure if lucee uses a synchronized struct.

Brad WoodApril 19, 2022 at 5:31 PM

This is because the struct that stores the interceptors internally is a Java instance of java.util.LinkedHashMap

And a LinkedHashMap is NOT threadsafe per the javadocs:

ColdBox needs to stop using un-synchronized Java classes. I would recommend ColdBox just start using a plain old CFML struct. Whatever performance gains Luis was getting back in the very very early days of ColdBox are likely to not exist any longer.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Fix versions

Priority

Sentry

Created April 19, 2022 at 4:52 PM
Updated May 4, 2022 at 11:00 PM
Resolved May 4, 2022 at 11:00 PM