azure-devops-java-sdk
azure-devops-java-sdk copied to clipboard
VariableGroupMap always assign the same value to variables
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);
}
}
Hiya @francispage, Thanks for pointing it out. If you can create a PR, I will merge the changes.
Hi @francispage, I've applied the fixed and released a new version 5.0.12.