Skip to content

The Unified and Autonomous Development Platform

Fix issue #720 - Closing an unsaved code comment results in NPE in diff view

Robin Shenfd9554dd70a1
diff --git a/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java b/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
index 51529a5966..b8d5abc7d5 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
@@ -1306,11 +1306,21 @@ public abstract class RevisionDiffPanel extends Panel {
public void onClick(AjaxRequestTarget target) {
CodeComment comment = annotationSupport.getOpenComment();
clearComment(target);
- BlobDiffPanel blobDiffPanel = getBlobDiffPanel(comment.getMark().getPath());
- if (blobDiffPanel != null)
- blobDiffPanel.onCommentClosed(target);
- annotationSupport.onCommentClosed(target);
- target.prependJavaScript("$('body').removeClass('hide-side-info');");
+ if (comment != null) {
+ BlobDiffPanel blobDiffPanel = getBlobDiffPanel(comment.getMark().getPath());
+ if (blobDiffPanel != null)
+ blobDiffPanel.onCommentClosed(target);
+ annotationSupport.onCommentClosed(target);
+ target.prependJavaScript("$('body').removeClass('hide-side-info');");
+ } else {
+ Mark mark = annotationSupport.getMark();
+ if (mark != null) {
+ BlobDiffPanel blobDiffPanel = getBlobDiffPanel(mark.getPath());
+ if (blobDiffPanel != null)
+ blobDiffPanel.unmark(target);
+ annotationSupport.onUnmark(target);
+ }
+ }
}
});