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 db0013a
Showing 1 changed file with 17 additions and 17 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 Expand Up @@ -517,7 +518,6 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
localZoweConfig ?: return ZoweConfigState.NOT_EXISTS
else
globalZoweConfig ?: return ZoweConfigState.NOT_EXISTS

if (findAllZosmfExistingConnection(type).isEmpty()) return ZoweConfigState.NEED_TO_ADD

val zoweConfigZosmfConnections = zoweConfig.getListOfZosmfConections()
Expand Down

0 comments on commit db0013a

Please sign in to comment.