Skip to content

Commit 1bd7386

Browse files
committed
Avoiding crash when unable to remove comment
1 parent 28ed7f9 commit 1bd7386

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/se/bjurr/violations/comments/bitbucketserver/lib/BitbucketServerCommentsProvider.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package se.bjurr.violations.comments.bitbucketserver.lib;
22

3-
import static com.google.common.base.Throwables.propagate;
43
import static com.google.common.collect.Lists.newArrayList;
54

65
import java.util.ArrayList;
76
import java.util.List;
87

8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
911
import se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerClient;
1012
import se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerComment;
1113
import se.bjurr.violations.comments.lib.model.ChangedFile;
@@ -14,6 +16,8 @@
1416

1517
public class BitbucketServerCommentsProvider implements CommentsProvider {
1618

19+
private static final Logger LOG = LoggerFactory.getLogger(BitbucketServerCommentsProvider.class);
20+
1721
private final BitbucketServerClient client;
1822

1923
private final ViolationCommentsToBitbucketServerApi violationCommentsToBitbucketApi;
@@ -78,12 +82,14 @@ public List<ChangedFile> getFiles() {
7882
@Override
7983
public void removeComments(List<Comment> comments) {
8084
for (Comment comment : comments) {
85+
Integer commentId = null;
86+
Integer commentVersion = null;
8187
try {
82-
Integer commentId = Integer.valueOf(comment.getIdentifier());
83-
Integer commentVersion = Integer.valueOf(comment.getSpecifics().get(0));
88+
commentId = Integer.valueOf(comment.getIdentifier());
89+
commentVersion = Integer.valueOf(comment.getSpecifics().get(0));
8490
this.client.pullRequestRemoveComment(commentId, commentVersion);
8591
} catch (Exception e) {
86-
throw propagate(e);
92+
LOG.warn("Was unable to remove comment " + commentId + " " + commentVersion, e);
8793
}
8894
}
8995
}

0 commit comments

Comments
 (0)