Merge changes I670a2bba,I0b36ba63
* changes:
Replace enable_context with enable-context in docs
Set path to null after filling the comment context
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index d897210..3f0c751 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -2052,7 +2052,7 @@
comments for each path are sorted by patch set number. Each comment has
the `patch_set` and `author` fields set.
-If the `enable_context` request parameter is set to true, the comment entries
+If the `enable-context` request parameter is set to true, the comment entries
will contain a list of link:#context-line[ContextLine] containing the lines of
the source file where the comment was written.
@@ -6699,7 +6699,7 @@
this comment applies.
|`context_lines` |optional|
A list of link:#context-line[ContextLine] containing the lines of the source
-file where the comment was written. Available only if the "enable_context"
+file where the comment was written. Available only if the "enable-context"
parameter (see link:#list-change-comments[List Change Comments]) is set.
|===========================
diff --git a/java/com/google/gerrit/server/restapi/change/CommentJson.java b/java/com/google/gerrit/server/restapi/change/CommentJson.java
index cc8ad47..02f39ab 100644
--- a/java/com/google/gerrit/server/restapi/change/CommentJson.java
+++ b/java/com/google/gerrit/server/restapi/change/CommentJson.java
@@ -123,7 +123,6 @@
list = new ArrayList<>();
out.put(o.path, list);
}
- o.path = null;
list.add(o);
}
@@ -133,10 +132,11 @@
loader.fill();
}
+ List<T> allComments = out.values().stream().flatMap(Collection::stream).collect(toList());
if (fillCommentContext) {
- List<T> allComments = out.values().stream().flatMap(Collection::stream).collect(toList());
addCommentContext(allComments);
}
+ allComments.forEach(c -> c.path = null); // we don't need path since it exists in the map keys
return out;
}