Fix creation of first key

This commit is contained in:
René Pfeuffer
2020-10-02 16:39:04 +02:00
parent bf0a477ab7
commit 50c0503531

View File

@@ -49,8 +49,13 @@ class ApiKeyCollection {
private Collection<ApiKeyWithPassphrase> keys;
public ApiKeyCollection add(ApiKeyWithPassphrase key) {
Collection<ApiKeyWithPassphrase> newKeys = new ArrayList<>(keys.size() + 1);
newKeys.addAll(keys);
Collection<ApiKeyWithPassphrase> newKeys;
if (keys == null) {
newKeys = new ArrayList<>();
} else {
newKeys = new ArrayList<>(keys.size() + 1);
newKeys.addAll(keys);
}
newKeys.add(key);
return new ApiKeyCollection(newKeys);
}