Skip to content

AFM.NativeTotalItem potential unsafe constructors #551

@martinmosko

Description

@martinmosko

While I was trying to work with NativeTotalItem.java. I found there one unnecessary attributeIdentifiers collection check in first constructor:

this.attributeIdentifiers = attributeIdentifiers == null ? Collections.emptyList() : attributeIdentifiers;

Problem is that this class has two constructors
NativeTotalItem(String, String...)
NativeTotalItem(String, List<String>)

So if accidentally somebody will create native total item in JSON with attributeIdentifiers = null this will fail as it would not be able to pick right constructor NativeTotalItem(String, null) matches both constructors.

I see here two options how to solve it:

a) remove null check in first constructor as its not needed
b) remove second constructor as they are pretty much the same and looks to me like shortcut

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions