Skip to content

VariableGroupMap always assign the same value to variables #73

@francispage

Description

@francispage

Good job for this library! I like it.

In VariableGroupMap you always set the same value to all variables so I had to override the method in a child class.

public class VariableGroupMap extends BaseAbstractMethod {
    private final Map<String, ConfigurationVariableValue> map = new HashMap<>();
    **private final ConfigurationVariableValue variableValue = new ConfigurationVariableValue();**

    public VariableGroupMap() {
    }

    public void put(String name, String value) {
        **variableValue.setValue(value);**
        map.put(name, variableValue); --> same reference used for all variables in the library
    }

You always use the same object so all variables have the same reference. ConfigurationVariableValue should be created each time so have different value per key.

I made it work with this hack:

public static class VariableGroupMapInternal extends VariableGroupMap {

        @Override
        public void put(String name, String value) {
            ConfigurationVariableValue variableValue = new ConfigurationVariableValue();
            variableValue.setValue(value);
            this.get().put(name, variableValue);
        }

    }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions