Fix NPE attempting to save draft comment with range
Change-Id: I0e3c734d7b6e232c6607a1768609a03ddaa6ea99
This commit is contained in:
@@ -215,6 +215,16 @@ public final class PatchLineComment {
|
||||
parentUuid = inReplyTo;
|
||||
}
|
||||
|
||||
public void setRange(Range r) {
|
||||
if (r != null) {
|
||||
range = new CommentRange(
|
||||
r.startLine, r.startCharacter,
|
||||
r.endLine, r.endCharacter);
|
||||
} else {
|
||||
range = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRange(CommentRange r) {
|
||||
range = r;
|
||||
}
|
||||
@@ -274,11 +284,4 @@ public final class PatchLineComment {
|
||||
builder.append('}');
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void fromRange(Range r) {
|
||||
range = r == null
|
||||
? null
|
||||
: new CommentRange(range.startLine, range.startCharacter,
|
||||
range.endLine, range.endCharacter);
|
||||
}
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ public class CreateDraft implements RestModifyView<RevisionResource, DraftInput>
|
||||
line, rsrc.getAccountId(), Url.decode(in.inReplyTo), now);
|
||||
c.setSide(in.side == Side.PARENT ? (short) 0 : (short) 1);
|
||||
c.setMessage(in.message.trim());
|
||||
c.fromRange(in.range);
|
||||
c.setRange(in.range);
|
||||
setCommentRevId(c, patchListCache, rsrc.getChange(), rsrc.getPatchSet());
|
||||
plcUtil.insertComments(db.get(), update, Collections.singleton(c));
|
||||
update.commit();
|
||||
|
@@ -115,7 +115,7 @@ public class PutDraft implements RestModifyView<DraftResource, DraftInput> {
|
||||
}
|
||||
e.setMessage(in.message.trim());
|
||||
if (in.range != null || in.line != null) {
|
||||
e.fromRange(in.range);
|
||||
e.setRange(in.range);
|
||||
e.setLine(in.range != null ? in.range.endLine : in.line);
|
||||
}
|
||||
e.setWrittenOn(TimeUtil.nowTs());
|
||||
|
Reference in New Issue
Block a user