MovingBlocks / gestalt

A family of libraries providing a variety of core capabilities for use by games and game engines.
Apache License 2.0
27 stars 23 forks source link

NullPointerException when module.txt contains an extra trailing comma #133

Open keturn opened 2 years ago

keturn commented 2 years ago

https://github.com/MovingBlocks/gestalt/blob/d97b8f7436aaea738226482f483f61bba612c5d9/gestalt-module/src/main/java/org/terasology/gestalt/module/dependencyresolution/ResolutionAttempt.java#L86-L91

Apparently ModuleMetadata.getDependencies can return a list with a null element when module.txt contains an extra trailing comma, as in the example below.

Could catch the null here, but probably better to fix it so that list can't contain null elements at all, even if the JSON is invalid.

[example module.txt] module.txt: ```json { "id": "BlockDetector", "version": "1.4.0-SNAPSHOT", "author": "rzats", "displayName": "BlockDetector", "description": "Adds a detector item that indicates the location of arbitrary blocks.", "dependencies": [ { "id": "CoreAssets", "minVersion": "2.0.0" }, { "id": "Inventory", "minVersion": "1.1.0" }, ], "serverSideOnly": false, "isAsset": true, "isLibrary": true } ```
youssef-abdallah commented 2 years ago

Probably the issue will be fixed by adding .setLenient() to GsonBuilder in the constructor of ModuleMetadataJsonAdapter. Is there any guide to contributing?

keturn commented 2 years ago

I'm not finding a gestalt-specific contributing guide, but you can refer to the one for Terasology: https://github.com/MovingBlocks/Terasology/blob/develop/.github/CONTRIBUTING.md

There are some differences. For one, I think gestalt needs to stay Android-compatible; it builds with an older Java source compatibility level than Terasology does.