From abcaae17abef5730c1db3a2e99c77f3d8c539cf9 Mon Sep 17 00:00:00 2001 From: tangcent Date: Sun, 31 Mar 2024 09:18:54 +0800 Subject: [PATCH] chore: fix compatibility issues in compatibility verification (#1117) --- .../idea/plugin/api/export/feign/FeignRequestClassExporter.kt | 3 +-- .../idea/plugin/api/export/http/HttpClientFileSaver.kt | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/feign/FeignRequestClassExporter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/feign/FeignRequestClassExporter.kt index 82e6af89d..3d0e64da3 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/feign/FeignRequestClassExporter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/feign/FeignRequestClassExporter.kt @@ -15,7 +15,6 @@ import com.itangcent.idea.plugin.api.export.condition.ConditionOnSimple import com.itangcent.idea.plugin.api.export.core.* import com.itangcent.idea.plugin.api.export.spring.SpringRequestClassExporter import com.itangcent.idea.plugin.condition.ConditionOnSetting -import org.apache.commons.lang.StringUtils.lowerCase /** * Support export apis from client that annotated with @FeignClient @@ -104,7 +103,7 @@ open class FeignRequestClassExporter : SpringRequestClassExporter() { val name = it.first val value = it.second.trim() if (name.equalIgnoreCase("content-type")) { - if (lowerCase(value).contains("application/json")) { + if (value.lowercase().contains("application/json")) { methodExportContext.setExt("paramType", "body") } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/http/HttpClientFileSaver.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/http/HttpClientFileSaver.kt index 505dff85e..9ce2ca607 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/http/HttpClientFileSaver.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/http/HttpClientFileSaver.kt @@ -11,9 +11,11 @@ import com.intellij.util.io.createDirectories import com.intellij.util.io.readText import com.itangcent.intellij.context.ActionContext import java.io.IOException +import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths +import kotlin.io.path.readText import kotlin.io.path.writeText /** @@ -67,7 +69,7 @@ class HttpClientFileSaver { val file = scratchesPath.resolve(module).resolve(fileName).apply { parent.createDirectories() } - file.writeText(content(file.takeIf { Files.exists(it) }?.readText())) + file.writeText(content(file.takeIf { Files.exists(it) }?.readText(StandardCharsets.UTF_8))) return (localFileSystem.refreshAndFindFileByPath(file.toString()) ?: throw IOException("Unable to find file: $file"))