)]}'
{
  "commit": "64e2fdc447a57218cbf0bf065c3baecf96e3b4f6",
  "tree": "fd906387fbc41d4bb6feb464060e9a5aba5451d5",
  "parents": [
    "341a8bd4e7c4623ee4e35bebeb608858cff0f429"
  ],
  "author": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Fri Dec 20 13:19:40 2019 +0100"
  },
  "committer": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Fri Dec 20 14:02:55 2019 +0100"
  },
  "message": "GetRelated: Handle index staleness for change on which the endpoint is invoked\n\nTo compute the related changes of a patch set we:\n\n1. Get all the groups from the patch sets of the corresponding change.\n2. Query for all changes in the project that have any of these groups.\n\nThe matched changes are then sorted by RelatedChangesSorter.\n\nIt is expected that the change for which the REST endpoint is invoked is\ncontained in the set of matched changes. Since we search by the change\u0027s\nproject and groups, it must always match.\n\nHowever the index can be stale for that change in two ways:\n\n1. The index knows the change but not yet the patch set for which the\n   REST endpoint is invoked.\n2. The index does not yet know the change for which the REST endpoint is\n   invoked.\n\nCase 1. was already handled by forcing a reload of the change when the\nwanted patch set was not present in the ChangeData that was returned\nfrom the index.\n\nThis change adds handling for case 2. If the change is missing in the\nindex result we now load its ChangeData from NoteDb and add it to the\nresult.\n\nIf the change is missing in the result then RelatedChangesSorter#sort\nfails with a NullPointerException because it doesn\u0027t find a commit for\nthe given start patch set [1] (the commits are gathered from the given\nchange set which is missing the change for the start patch set).\n\n[1]\njava.lang.NullPointerException: commit b0f113907a693dbf911f5721afb5332647ed6990 of patch set 121,1 not found in {936be82cf638c033e1674c19b086bc0af8b07300\u003d122,1, 2e5531ccee8872ddfb6595798416512f0fe6dec0\u003d123,1}\n        at java.util.Objects.requireNonNull(Objects.java:290)\n        at com.google.gerrit.server.restapi.change.RelatedChangesSorter.sort(RelatedChangesSorter.java:80)\n        at com.google.gerrit.server.restapi.change.GetRelated.getRelated(GetRelated.java:103)\n        at com.google.gerrit.server.restapi.change.GetRelated.apply(GetRelated.java:76)\n        at com.google.gerrit.server.restapi.change.GetRelated.apply(GetRelated.java:52)\n        at com.google.gerrit.httpd.restapi.RestApiServlet.lambda$invokeRestReadViewWithRetry$3(RestApiServlet.java:741)\n        ....\n\nSigned-off-by: Edwin Kempin \u003cekempin@google.com\u003e\nChange-Id: I9a94d734aed5a84c8d9510f6fcc5baca4c3416e2\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "a846d50f1cf6d5cae5c8fe1165bf389925e3c6a8",
      "old_mode": 33188,
      "old_path": "java/com/google/gerrit/server/restapi/change/GetRelated.java",
      "new_id": "5f075f667b9c6cc38d86300ef29d221c9730780c",
      "new_mode": 33188,
      "new_path": "java/com/google/gerrit/server/restapi/change/GetRelated.java"
    }
  ]
}
