gestalt icon indicating copy to clipboard operation
gestalt copied to clipboard

NullPointerException when module.txt contains an extra trailing comma

Open keturn opened this issue 3 years ago • 2 comments

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:

{
  "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
}

keturn avatar May 19 '22 19:05 keturn

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

youssef-abdallah avatar May 20 '22 15:05 youssef-abdallah

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.

keturn avatar May 20 '22 19:05 keturn