Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
codex128 opened this issue Mar 20, 2024 · 1 comment · Fixed by #2232
Closed

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

codex128 opened this issue Mar 20, 2024 · 1 comment · Fixed by #2232
Labels
defect Something that is supposed to work, but doesn't. Less severe than a "bug"
Milestone

Comments

@codex128
Copy link
Contributor

codex128 commented Mar 20, 2024

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.

@codex128
Copy link
Contributor Author

On closer inspection, the necessary information is logged, but on the FINER level. I think this should be changed to SEVERE, since a failure here results in a null pointer later.

logger.throwing(type.getName(), "<init>", ex);

@stephengold stephengold added the defect Something that is supposed to work, but doesn't. Less severe than a "bug" label Oct 22, 2024
@stephengold stephengold added this to the v3.7.0 milestone Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something that is supposed to work, but doesn't. Less severe than a "bug"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants