fix: 修复因 config.json 不存在而引发的启动异常.

当 config.json 不存在时, 当 Launcher 类被加载时, 将导致因 config.json 加载失败而出现类初始化异常, 通过调整访问时机, 修复了这个问题.
This commit is contained in:
LamGC 2022-02-26 17:36:23 +08:00
parent a642948f45
commit 285c8b04d1
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -53,11 +53,6 @@ internal class Launcher : AutoCloseable {
private val botApi = TelegramBotsApi(DefaultBotSession::class.java) private val botApi = TelegramBotsApi(DefaultBotSession::class.java)
private val botSessionMap = mutableMapOf<ScalaBot, BotSession>() private val botSessionMap = mutableMapOf<ScalaBot, BotSession>()
private val remoteRepositories = Const.config.mavenRepositories
.map(MavenRepositoryConfig::toRemoteRepository)
.toMutableList().apply {
add(MavenRepositoryExtensionFinder.getMavenCentralRepository(proxy = Const.config.proxy.toAetherProxy()))
}.toList()
@Synchronized @Synchronized
fun launch(): Boolean { fun launch(): Boolean {
@ -99,6 +94,12 @@ internal class Launcher : AutoCloseable {
} }
} }
val account = botConfig.account val account = botConfig.account
val remoteRepositories = Const.config.mavenRepositories
.map(MavenRepositoryConfig::toRemoteRepository)
.toMutableList().apply {
add(MavenRepositoryExtensionFinder.getMavenCentralRepository(proxy = Const.config.proxy.toAetherProxy()))
}.toList()
val extensionPackageFinders = setOf( val extensionPackageFinders = setOf(
MavenRepositoryExtensionFinder( MavenRepositoryExtensionFinder(
remoteRepositories = remoteRepositories, remoteRepositories = remoteRepositories,