Fix NPE when submitting review with inline comments via REST
NPE occurs when submitting a review with inline comments in
the format:
{
"comments": {
"test.txt": [
{
"line": 1,
"message": "comment"
},
]
}
}
The comma following the closing brace after the `"message": "comment"`
line seems to be causing an iterator with a null element to be
generated.
NPE does not occur when the comma is omitted.
To prevent the NPE remove the null element from the iterator.
Change-Id: I248739fce955522f7ee4a93441e48914342d3d7d
This commit is contained in:
@@ -282,6 +282,10 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
Iterator<Comment> listItr = list.iterator();
|
||||
while (listItr.hasNext()) {
|
||||
Comment c = listItr.next();
|
||||
if (c == null) {
|
||||
listItr.remove();
|
||||
continue;
|
||||
}
|
||||
if (c.line < 0) {
|
||||
throw new BadRequestException(String.format(
|
||||
"negative line number %d not allowed on %s",
|
||||
|
||||
Reference in New Issue
Block a user