diff --git a/components/engine/engine-cms-internal/src/main/java/org/eclipse/dirigible/components/engine/cms/internal/CmsProviderInternalFactory.java b/components/engine/engine-cms-internal/src/main/java/org/eclipse/dirigible/components/engine/cms/internal/CmsProviderInternalFactory.java index 03cea7f1046..cc11fb575f3 100644 --- a/components/engine/engine-cms-internal/src/main/java/org/eclipse/dirigible/components/engine/cms/internal/CmsProviderInternalFactory.java +++ b/components/engine/engine-cms-internal/src/main/java/org/eclipse/dirigible/components/engine/cms/internal/CmsProviderInternalFactory.java @@ -22,6 +22,8 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; /** * A factory for creating CmsProviderInternal objects. @@ -38,6 +40,9 @@ class CmsProviderInternalFactory implements CmsProviderFactory { /** The default tenant. */ private final Tenant defaultTenant; + /** The Constant PROVIDERS. */ + private static final Map PROVIDERS = new HashMap(); + /** * Instantiates a new cms provider internal factory. * @@ -59,8 +64,12 @@ public CmsProvider create() { String rootFolder = DirigibleConfig.CMS_INTERNAL_ROOT_FOLDER.getStringValue() + getTenantFolder(); Path path = Paths.get(rootFolder); boolean absolutePath = path.isAbsolute(); - - return new CmsProviderInternal(rootFolder, absolutePath); + if (PROVIDERS.containsKey(rootFolder)) { + return PROVIDERS.get(rootFolder); + } + CmsProviderInternal cmsProviderInternal = new CmsProviderInternal(rootFolder, absolutePath); + PROVIDERS.put(rootFolder, cmsProviderInternal); + return cmsProviderInternal; } /**