Concurrency issues when reading the .cfg file

Enonic version: 7.15.1

OS: Ubuntu 24.04

We implemented a library project, which is used by multiple apps. Within this project, we implemented a function to read keys from a .cfg file.

The idea is to have a single .cfg file com.company.myapp that is read by other apps. And these multiple apps can share the same server.

We use an approach similar to what was done in this content studio code (which reads a configuration file from another app): https://github.com/enonic/app-contentstudio/blob/master/modules/app/src/main/java/com/enonic/app/main/MarketConfigService.java

However, I noticed that when multiple apps import my library and try to read the same .cfg file, only one of them receives the content. The other apps receives an empty content.

I know this is a very specific approach that I didn’t find in the official Enonic documentation, but is there any way to deal with this?

Just to set expectations: config file handling isn’t really an XP feature — XP only watches the .cfg files and forwards changes to OSGi (Felix ConfigAdmin), which then pushes them to the consuming components.

We use this internally and haven’t seen anything like what you describe.

What’s “special” in your case is the library usage: technically you end up with as many copies of the “same” class as there are apps depending on that lib, which can confuse the OSGi framework.