fix(config): 修复潜在的无状况错误问题.

由于在 MavenRepositoryConfigSerializer 反序列化中过滤了 Json 的类型, 导致用户在配置中使用了错误的 Json 数据类型将不会有任何错误信息.
该改动已解决该问题.
This commit is contained in:
LamGC 2022-06-26 02:42:35 +08:00
parent 045b3e5d54
commit c7c24fa454
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 4 additions and 5 deletions

View File

@ -115,16 +115,16 @@ object MavenRepositoryConfigSerializer
MavenRepositoryConfig(
id = json.get("id")?.asString,
url = URL(SerializerUtils.checkJsonKey(json, "url")),
proxy = if (json.has("proxy") && json.get("proxy").isJsonObject)
proxy = if (json.has("proxy"))
context.deserialize<Proxy>(
json.getAsJsonObject("proxy"), Proxy::class.java
json.get("proxy"), Proxy::class.java
) else null,
layout = json.get("layout")?.asString ?: "default",
enableReleases = json.get("enableReleases")?.asBoolean ?: true,
enableSnapshots = json.get("enableSnapshots")?.asBoolean ?: true,
authentication = if (json.has("authentication") && json.get("authentication").isJsonObject)
authentication = if (json.has("authentication"))
context.deserialize<Authentication>(
json.getAsJsonObject("authentication"), Authentication::class.java
json.get("authentication"), Authentication::class.java
) else null
)
}

View File

@ -227,7 +227,6 @@ internal class MavenRepositoryConfigSerializerTest {
// ------------------------------------
jsonObject.add("authentication", JsonArray())
jsonObject.add("layout", mockk<JsonPrimitive> {
every { asString }.returns(null)
})