[Bug] DefaultGameRepository存在时序竞态导致切换实例列表时崩溃
问题描述 | Bug Description
在HMCL未完成实例列表加载之前切换到另一个实例文件夹会导致空指针
启动器崩溃报告 / 启动器日志文件 | Launcher Crash Report / Launcher Log File
---- Hello Minecraft! Crash Report ---- Version: 3.16.SNAPSHOT Time: 2026-06-27 22:24:29 Thread: Thread[#38,JavaFX Application Thread,5,main]
Content: java.lang.NullPointerException: Cannot invoke "java.util.Map.containsKey(Object)" because "this.versions" is null at org.jackhuang.hmcl.game.DefaultGameRepository.hasVersion(DefaultGameRepository.java:71) at org.jackhuang.hmcl.ui.versions.GameAdvancedListItem.loadVersion(GameAdvancedListItem.java:60) at org.jackhuang.hmcl.ui.FXUtils.lambda$onWeakChange$3(FXUtils.java:276) at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86) at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:386) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.base/javafx.beans.property.ReadOnlyStringPropertyBase.fireValueChangedEvent(ReadOnlyStringPropertyBase.java:78) at javafx.base/javafx.beans.property.ReadOnlyStringWrapper.fireValueChangedEvent(ReadOnlyStringWrapper.java:103) at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111) at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145) at org.jackhuang.hmcl.setting.Profiles.lambda$init$3(Profiles.java:175) at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:386) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.base/javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106) at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113) at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147) at org.jackhuang.hmcl.setting.Profiles.setSelectedProfile(Profiles.java:425) at org.jackhuang.hmcl.ui.profile.ProfileListItemSkin.lambda$new$1(ProfileListItemSkin.java:48) at org.jackhuang.hmcl.ui.FXUtils.lambda$onClicked$26(FXUtils.java:1430) at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247) at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.base/javafx.event.Event.fireEvent(Event.java:198) at javafx.graphics/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3688) at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3993) at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1890) at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2708) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449) at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:551) at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:937) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185) at java.base/java.lang.Thread.run(Thread.java:1583)
-- System Details -- Operating System: Windows 11 25H2 10.0.26200.8737 System Architecture: x86-64 Java Architecture: x86-64 Java Version: 21.0.9, BellSoft Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), BellSoft JVM Max Memory: 1073741824 JVM Total Memory: 146800640 JVM Free Memory: 84062960