Skip to content

Bug: Immutable type created, causes exception to be thrown #59

@sw-tracker

Description

@sw-tracker

Hi @dabeeeenster ,

We are using this library with kotlin and we are getting exceptions when the feature flag list needs to be extended because the flag is missing in the server. The reason is that the feature flag list is created as immutable.

Here is where the code needs to be fixed:

file: FlagsmithApiWrapper.java

// from:
List<Flag> featureFlags = Arrays.asList(mapper.readValue(response.body().string(),
            Flag[].class));

// to:
List<Flag> featureFlags = new ArrayList<>(Arrays.asList(
            mapper.readValue(response.body().string(),
            Flag[].class)));

Maybe you should double check everywhere where Arrays.asList is used (as this creates an immutable list). If the list needs to be modifiable then wrapping it with new ArrayList<>() should fix it (this creates a mutable list).

Cheers,
Olga

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