From 6b8b0ae2f859cab42dbf89e8b513bad4e9432aec Mon Sep 17 00:00:00 2001 From: tangcent Date: Sun, 31 Mar 2024 07:58:11 +0800 Subject: [PATCH] fix: implement error handling in remoteConfigContent function (#1115) --- .../helper/RemoteConfigSettingsHelper.kt | 9 ++++++++- .../main/resources/.recommend.easy.api.config | 16 ++++++++-------- .../api/cache/CachedRequestClassExporterTest.kt | 3 +-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RemoteConfigSettingsHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RemoteConfigSettingsHelper.kt index 18db20ccf..9ea8847cb 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RemoteConfigSettingsHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RemoteConfigSettingsHelper.kt @@ -41,7 +41,14 @@ class RemoteConfigSettingsHelper { return settingBinder.read().remoteConfig .parse() .filter { it.first } - .map { loadConfig(it.second) } + .mapNotNull { + try { + loadConfig(it.second) + } catch (e: Exception) { + logger.error("failed to load config: ${it.second}") + null + } + } } fun loadConfig(url: String): ConfigContent { diff --git a/idea-plugin/src/main/resources/.recommend.easy.api.config b/idea-plugin/src/main/resources/.recommend.easy.api.config index 971be49df..2b185af2e 100644 --- a/idea-plugin/src/main/resources/.recommend.easy.api.config +++ b/idea-plugin/src/main/resources/.recommend.easy.api.config @@ -228,7 +228,7 @@ check_annotated_Validated=``` return } ``` -check_groups=``` +check_groups_jakarta=``` for(annMap in annMaps){ def fieldGroups = annMap["groups"] ?: [helper.findClass("jakarta.validation.groups.Default")] def paramGroups = session.get("json-group") ?: [helper.findClass("jakarta.validation.groups.Default")] @@ -245,17 +245,17 @@ check_groups=``` field.required[@jakarta.validation.constraints.NotBlank]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("jakarta.validation.constraints.NotBlank") - ${check_groups} + ${check_groups_jakarta} ``` field.required[@jakarta.validation.constraints.NotNull]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("jakarta.validation.constraints.NotNull") - ${check_groups} + ${check_groups_jakarta} ``` field.required[@jakarta.validation.constraints.NotEmpty]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("jakarta.validation.constraints.NotEmpty") - ${check_groups} + ${check_groups_jakarta} ``` @@ -291,7 +291,7 @@ check_annotated_Validated=``` return } ``` -check_groups=``` +check_groups_javax=``` for(annMap in annMaps){ def fieldGroups = annMap["groups"] ?: [helper.findClass("javax.validation.groups.Default")] def paramGroups = session.get("json-group") ?: [helper.findClass("javax.validation.groups.Default")] @@ -308,17 +308,17 @@ check_groups=``` field.required[@javax.validation.constraints.NotBlank]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("javax.validation.constraints.NotBlank") - ${check_groups} + ${check_groups_javax} ``` field.required[@javax.validation.constraints.NotNull]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("javax.validation.constraints.NotNull") - ${check_groups} + ${check_groups_javax} ``` field.required[@javax.validation.constraints.NotEmpty]=groovy:``` ${check_annotated_Validated} def annMaps = it.annMaps("javax.validation.constraints.NotEmpty") - ${check_groups} + ${check_groups_javax} ``` #[is_file]* diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/cache/CachedRequestClassExporterTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/cache/CachedRequestClassExporterTest.kt index 4ed1948f3..3893c8d55 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/cache/CachedRequestClassExporterTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/cache/CachedRequestClassExporterTest.kt @@ -126,8 +126,7 @@ internal class CachedRequestClassExporterTest : PluginContextLightCodeInsightFix Mockito.verify(delegateClassExporter, times(1)) .export(any(), any()) - TimeUnit.SECONDS.sleep(10)//wait 10s to save cache - + boundary.waitComplete(TimeUnit.SECONDS.toMillis(10),false)//wait 10s to save cache //export again val requestsAgain = ArrayList() classExporter.export(userCtrlPsiClass, requestOnly {