Uploaded image for project: 'Skara'
  1. Skara
  2. SKARA-1569

The method 'IssueWorkItem#run' may get the wrong pull request

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.0
    • None
    • bots
    • None

      When one issue has two PRs in the same repository and one PR is in state `open` and another PR is in state `closed`, the method 'IssueWorkItem#run' may get the wrong PR which is in state `closed`.

      The related code is shown below. The `findAny` method causes this bug. We should get all the corresponding PRs firstly and then filter the open PRs.

      ```

              Stream.concat(mainIssue.stream(), backports.stream())
                      .flatMap(i -> PullRequestUtils.pullRequestCommentLink(i).stream())
                      .map(uri -> bot.repositories().stream()
                              .map(r -> r.parsePullRequestUrl(uri.toString()))
                              .flatMap(Optional::stream)
                              .findAny())
                      .flatMap(Optional::stream)
                      .map(pr -> new PullRequestWorkItem(pr.repository(), pr.id(), csrIssue.project()))
                      .forEach(ret::add);
      ```

            gli Guoxiong Li
            gli Guoxiong Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: