From f6df4c1db4d4cc335ceb0cad6f0f32e92d3f9751 Mon Sep 17 00:00:00 2001 From: Katsiaryna Tsytsenia Date: Sun, 9 Feb 2025 10:22:34 +0200 Subject: [PATCH] GH-232 Fixed slow operations on EDT in scanForZoweConfig method Signed-off-by: Katsiaryna Tsytsenia --- .../zowe/service/ZoweConfigServiceImpl.kt | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index bba73979..15960a4c 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -163,25 +163,26 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService * @return ZoweConfig instance if zowe.config.json is presented or null otherwise. */ private fun scanForZoweConfig(type: ZoweConfigType): ZoweConfig? { - - val zoweFile = runReadAction { - VirtualFileManager.getInstance().findFileByNioPath(Path.of(getZoweConfigLocation(myProject, type))) - } ?: return null - return try { - zoweFile.inputStream.use { zoweFileInputStream -> - parseConfigJson(zoweFileInputStream).also { tmpZoweConfig -> - tmpZoweConfig.extractSecureProperties(zoweFile.path.split("/").toTypedArray()) - lock.write { - if (type == ZoweConfigType.LOCAL) - localZoweConfig = tmpZoweConfig - else - globalZoweConfig = tmpZoweConfig + return runTask(title = "Scanning for ${type} zowe config file", project = myProject) { + val zoweFile = runReadAction { + VirtualFileManager.getInstance().findFileByNioPath(Path.of(getZoweConfigLocation(myProject, type))) + } ?: return@runTask null + return@runTask try { + zoweFile.inputStream.use { zoweFileInputStream -> + parseConfigJson(zoweFileInputStream).also { tmpZoweConfig -> + tmpZoweConfig.extractSecureProperties(zoweFile.path.split("/").toTypedArray()) + lock.write { + if (type == ZoweConfigType.LOCAL) + localZoweConfig = tmpZoweConfig + else + globalZoweConfig = tmpZoweConfig + } } } + } catch (e: Exception) { + NotificationsService.errorNotification(e, project = myProject, custTitle = "Error with Zowe config file") + return@runTask null } - } catch (e: Exception) { - NotificationsService.errorNotification(e, project = myProject, custTitle="Error with Zowe config file") - return null } }