Skip to content

Unclear exception info on invalid file path in asset locator #2230

Closed
@codex128

Description

@codex128

If an asset locator is registered with a nonexistent file path and then the system tries to locate an asset with it, a very unclear warning occurs followed by a null pointer exception.

assetManager.registerLocator("NonExistentFolder", FileLocator.class);
assetManager.loadModel("NonExistentModel.j3o");
SEVERE: Cannot create locator of type com.jme3.asset.plugins.FileLocator, does the class have an empty and publicly accessible constructor?
Mar 20, 2024 9:14:45 AM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException: Cannot invoke "com.jme3.asset.AssetLocator.locate(com.jme3.asset.AssetManager, com.jme3.asset.AssetKey)" because the return value of "com.jme3.asset.ImplHandler$ImplThreadLocal.get()" is null
	at com.jme3.asset.ImplHandler.tryLocate(ImplHandler.java:176)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:376)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:441)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:446)
	at mygame.GeneralTests.simpleInitApp(GeneralTests.java:24)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:610)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:714)
	at java.base/java.lang.Thread.run(Thread.java:833)

The warning/exception should instead indicate that a nonexistent path is being used. I am working on a PR to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSomething that is supposed to work, but doesn't. Less severe than a "bug"

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions