fix: 修复由于 json 文件为空, 导致的 NPE.

由于 json 文件为空, 当 Gson 解析空文件时, 将返回 null.
This commit is contained in:
LamGC 2021-08-15 23:14:04 +08:00
parent 765b13f149
commit d81d07bd65
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -133,6 +133,11 @@ public final class SshAuthIdentityProvider {
}
Map<String, SshAuthInfo> map = gson.fromJson(new FileReader(identityJsonFile, StandardCharsets.UTF_8),
new TypeToken<Map<String, SshAuthInfo>>(){}.getType());
if (map == null) {
log.warn("没有可用的 SSH 认证配置.");
return;
}
for (String id : map.keySet()) {
SshAuthInfo info = map.get(id);
info.setProvider(this);