Skip to content

Commit

Permalink
GH-232 Fixed slow operations on EDT in scanForZoweConfig method
Browse files Browse the repository at this point in the history
Signed-off-by: Katsiaryna Tsytsenia <[email protected]>
  • Loading branch information
ktsytsen committed Feb 9, 2025
1 parent ab206ca commit f6df4c1
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit f6df4c1

Please sign in to comment.