From c1c97db8708f26af10385f6e86af7cd933891bb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 17 Jul 2023 00:57:44 +0200 Subject: [PATCH] fix: ensure configuration section cache is always initialized MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Configuration.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index ae3d8e9f..66abd3e1 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -52,6 +52,34 @@ export class Configuration { } public static getConfigurationSection(sectionName: ConfigurationSection): T { + if (!Configuration.configurationSectionCache.has(sectionName)) { + switch (sectionName) { + case ConfigurationSection.log: + Configuration.configurationSectionCache.set(sectionName, Configuration.buildLogSection()); + break; + case ConfigurationSection.performanceStorage: + Configuration.configurationSectionCache.set( + sectionName, + Configuration.buildPerformanceStorageSection(), + ); + break; + case ConfigurationSection.worker: + Configuration.configurationSectionCache.set( + sectionName, + Configuration.buildWorkerSection(), + ); + break; + case ConfigurationSection.uiServer: + Configuration.configurationSectionCache.set( + sectionName, + Configuration.buildUIServerSection(), + ); + break; + default: + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(`Unknown configuration section '${sectionName}'`); + } + } return Configuration.configurationSectionCache.get(sectionName) as T; } -- 2.34.1