Skip to content

ClassCastException for empty transformations #9

@sgaragan

Description

@sgaragan

If a transformation returns an empty transformation (not null and not an empty list, equivalent of { } for JSON), a ClassCastException is thrown and the following comes out in the logs:

class java.util.HashMap cannot be cast to class java.util.List (java.util.HashMap and java.util.List are in module java.base of loader 'bootstrap')

The issue seems to be at com.swisscom.daisy.cosmos.candyfloss.transformations.Transformer:35 which is the transformList() method. There is an unsafe cast at line 36:

var transformed = (List<Map<String, Object>>) chainr.transform(input.json());

The code checks to see if this returns null but not an empty HashMap. Not entirely sure why an empty HashMap gets returned instead of null but that is somewhat separate from this

Thanks,
Sean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions