tracker issue : CF-4198397

select a category, or use search below
(searches all categories and all time range)
Title:

App-specific mappings added outside of Application.cfc can dissappear

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()

Created: 03/11/2017

Components: Language, Framework Support

Versions: 2016

Failure Type: Data Corruption

Found In Build/Fixed In Build: 9, 10, 11, 2016 /

Priority/Frequency: Normal / Most users will encounter

Locale/System: ALL / Platforms All

Vote Count: 5

Problem Description:
The ColdBox framework makes use of app-specific mappings that are added inside the framework to allow for portability of modules.  We have a slightly different way we achieve it on CF9, CF10, and CF11/2016, but the basic gist is that we get the current mappings from the application metadata and append items to the array which can be immediately used to create CFCs and resolve file paths.  

var appSettings = getApplicationMetadata();
appSettings.mappings[ '/foo' ] = '/path/to/foo';

This works great, but we occasionally have received reports from users about getting errors creating CFCs that seems to imply that the mappings are not always present.  Evagoras was able to construct a sample app that shows this concurrency issue very well.  Basically the array often times only contains some of the mappings, or in many cases is completely empty!  The mappings are re-added on every request since the array of mappings defaults back to what's defined in the Application.cfc so the array should be unique to a request, but there is some sort of concurrency issue where the array is not thread safe and sometimes is in an inconsistent state.  This is a very bad issue for everyone running the ColdBox framework since we rely on these mappings to be created and exist for all our modules.  I tried placing exclusive locks around the setting and reading of mappings, but it had no affect.  

Steps to Reproduce:

Here is a sample code repo on GitHub 
https://github.com/evagoras/acf_mappings_thread_safety_issue

You can install this code and run it with CommandBox very easily.  The Github readme shows you how to use the included Jmeter file to put some load on the site.  Then you can view the dump.html page and see all of the errors that occurred.  Instead of all 5 mappings being available on every request many requests will be missing mappings or have none at all..

Any Workarounds:

As a workaround, the CF mappings can be added to the Application.cfc this.mappings, but that defeats the purpose of modules that can be installed or uninstalled and be completely self-contained.

Attachments:

Comments:

I think this ticket might be related to https://tracker.adobe.com/#/view/CF-4198394
Comment by Bradley W.
1110 | March 11, 2017 03:34:24 AM GMT
Verified in most recent beta ColdFusion 2018 and ColdBox 5.0.0 RC1
Vote by Philipp C.
27555 | April 18, 2018 12:41:08 PM GMT