为什么关闭JIRA机票会导致死锁?

时间:2019-04-24 15:42:44

标签: java rest client jira deadlock

我试图使用JIRA REST JAVA CLIENT API通过票证的issueID关闭票证(设置状态为“已关闭”)。

当使用.done(x->y)链接异步调用时,最后一个调用在调用transition的第一行中以JIRA客户端方法getServerInfo().claim();内部的死锁结束。

当我到处使用阻塞调用.claim()时,代码将起作用,但也会阻塞应用程序4秒钟。

public void closeIssue(String issueId) {
    final IssueRestClient issueClient = jiraRestClient.getIssueClient();
    issueClient.getIssue(issueId).done(issue ->
    {
        issueClient.getTransitions(issue.getTransitionsUri()).done(transitions ->
        {
            final Optional<Transition> closedTransition = 

            getTransitionByName(transitions, "Closed");
            closedTransition
                    .map(Transition::getId)
                    .map(TransitionInput::new)
                    .ifPresent(transitionInput ->
                            issueClient.transition(
                                    issue.getTransitionsUri(),
                                    transitionInput
                                ).done(log()));
        });
    });
}

private Consumer<Void> log(String issueId) {
    return aVoid -> LOG.info("Closed JIRA issue {}!", issueId);
}

private static Optional<Transition> getTransitionByName(
        Iterable<Transition> transitions, 
        String transitionName
) {
    return StreamSupport
            .stream(transitions.spliterator(), false)
            .filter(t->t.getName().equals(transitionName))
            .findFirst();
}

该如何解决?

0 个答案:

没有答案