mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
fix(config): 修复潜在的无状况错误问题.
由于在 MavenRepositoryConfigSerializer 反序列化中过滤了 Json 的类型, 导致用户在配置中使用了错误的 Json 数据类型将不会有任何错误信息. 该改动已解决该问题.
This commit is contained in:
parent
045b3e5d54
commit
c7c24fa454
@ -115,16 +115,16 @@ object MavenRepositoryConfigSerializer
|
|||||||
MavenRepositoryConfig(
|
MavenRepositoryConfig(
|
||||||
id = json.get("id")?.asString,
|
id = json.get("id")?.asString,
|
||||||
url = URL(SerializerUtils.checkJsonKey(json, "url")),
|
url = URL(SerializerUtils.checkJsonKey(json, "url")),
|
||||||
proxy = if (json.has("proxy") && json.get("proxy").isJsonObject)
|
proxy = if (json.has("proxy"))
|
||||||
context.deserialize<Proxy>(
|
context.deserialize<Proxy>(
|
||||||
json.getAsJsonObject("proxy"), Proxy::class.java
|
json.get("proxy"), Proxy::class.java
|
||||||
) else null,
|
) else null,
|
||||||
layout = json.get("layout")?.asString ?: "default",
|
layout = json.get("layout")?.asString ?: "default",
|
||||||
enableReleases = json.get("enableReleases")?.asBoolean ?: true,
|
enableReleases = json.get("enableReleases")?.asBoolean ?: true,
|
||||||
enableSnapshots = json.get("enableSnapshots")?.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>(
|
context.deserialize<Authentication>(
|
||||||
json.getAsJsonObject("authentication"), Authentication::class.java
|
json.get("authentication"), Authentication::class.java
|
||||||
) else null
|
) else null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,6 @@ internal class MavenRepositoryConfigSerializerTest {
|
|||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
jsonObject.add("authentication", JsonArray())
|
|
||||||
jsonObject.add("layout", mockk<JsonPrimitive> {
|
jsonObject.add("layout", mockk<JsonPrimitive> {
|
||||||
every { asString }.returns(null)
|
every { asString }.returns(null)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user