Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ abstract class ListRequest {

public List<GroupInfo> get() throws RestApiException {
Map<String, GroupInfo> map = getAsMap();
List<GroupInfo> result = new ArrayList<>(map.size());
for (Map.Entry<String, GroupInfo> e : map.entrySet()) {
// ListGroups "helpfully" nulls out names when converting to a map.
e.getValue().name = e.getKey();
result.add(e.getValue());
}
List<GroupInfo> result = new ArrayList<>(map.values());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files in the com.google package should not be touched as these are copied over from official Gerrit source from time to time. Does your "fix" also work without this change? Or do you see any alternatives to fix this issue?

// for (Map.Entry<String, GroupInfo> e : map.entrySet()) {
// // ListGroups "helpfully" nulls out names when converting to a map.
// e.getValue().name = e.getKey();
// result.add(e.getValue());
// }
return Collections.unmodifiableList(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import com.google.gson.JsonElement;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.SortedMap;
import java.util.*;

/**
* @author Shawn Stafford
Expand Down Expand Up @@ -55,6 +52,11 @@ public List<GroupInfo> parseGroupInfos(JsonElement result) {
return gson.fromJson(result, GROUP_LIST_TYPE);
} else {
SortedMap<String, GroupInfo> map = gson.fromJson(result, GROUP_MAP_TYPE);
if (map != null && !map.isEmpty()) {
for (Map.Entry<String, GroupInfo> groupInfoEntry : map.entrySet()) {
groupInfoEntry.getValue().name = groupInfoEntry.getKey();
}
}
return new ArrayList<GroupInfo>(map.values());
}
}
Expand Down