Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-232 Fixed slow operations on EDT in scanForZoweConfig method #311

Open
wants to merge 1 commit into
base: release/v2.1.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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