Magic behind AccountInfoCache

30 views
Skip to first unread message

Tomasz Zarna

unread,
Aug 1, 2013, 10:20:47 AM8/1/13
to repo-d...@googlegroups.com
Hi guys,

Can someone explain to me the magic behind AccountInfoCache map [1] returned as part of ChangeDetail [2]? Why there are cases when the map doesn't contain all reviewers for a given change?

For instance, when calling changeDetail method from RCP API for https://git.eclipse.org/r/#/c/4718/ I get (preferredEmail fields removed):

{
    "jsonrpc" : "2.0",
    "id" : 1,
    "result" : {
        "accounts" : {
            "accounts" : [{
                    "id" : 1
                }, {
                    "id" : {                   
                          "id" : 1
                    },
                    "fullName" : "Shawn Pearce",
                }, {
                    "id" : 118
                }, {
                    "id" : {
                        "id" : 118
                    },
                    "fullName" : "Tomasz Zarna",
                }, {
                }, {
                    "id" : 8
                    "id" : {
                        "id" : 8
                    },
                    "fullName" : "Robin Rosenberg",
                }, {
                    "id" : 107
                }, {
                    "id" : {
                        "id" : 107
                    },
                    "fullName" : "Hudson CI",
                }
            ]
        },
...

But when listing reviewers with REST API (GET /changes/4718/reviewers/), I get them all, including Chris:

[
  {
    "kind": "gerritcodereview#reviewer",
    "approvals": {
      "IP-Clean": " 0"
    },
    "_account_id": 1,
    "name": "Shawn Pearce",
  },
  {
    "kind": "gerritcodereview#reviewer",
    "approvals": {
      "IP-Clean": " 0"
    },
    "_account_id": 2,
    "name": "Chris Aniszczyk",
  },
  {
    "kind": "gerritcodereview#reviewer",
    "approvals": {
      "Verified": " 0",
      "Code-Review": "+2",
      "IP-Clean": "+1"
    },
    "_account_id": 8,
    "name": "Robin Rosenberg",
  },
  {
    "kind": "gerritcodereview#reviewer",
    "approvals": {
      "Code-Review": " 0"
    },
    "_account_id": 107,
    "name": "Hudson CI",
  }
]

The interesting thing is that we have started noticing it after switching to Gerrit 2.6. But even in previous versions I was able to find some quirks like the cache (the accounts field) containing users not mentioned on the change.

Cheers,
Tomek

[1] https://gerrit.googlesource.com/gerrit/+/master/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountInfoCache.java
[2] https://gerrit.googlesource.com/gerrit/+/master/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java

Shawn Pearce

unread,
Aug 5, 2013, 1:02:30 PM8/5/13
to Tomasz Zarna, repo-discuss
On Thu, Aug 1, 2013 at 7:20 AM, Tomasz Zarna <tomasz...@tasktop.com> wrote:
> Can someone explain to me the magic behind AccountInfoCache map [1] returned
> as part of ChangeDetail [2]? Why there are cases when the map doesn't
> contain all reviewers for a given change?
>
> For instance, when calling changeDetail method from RCP API for
> https://git.eclipse.org/r/#/c/4718/ I get (preferredEmail fields removed):

I'm not sure its worth trying to explain. The new /changes/ REST API
will replace ChangeDetail very soon.

As for why the users are possibly different then expected, the map is
populated separately from the JSON response construction and it can
lead to differences. The way this is handled in the newer REST APIs
its less likely to happen as the AccountInfo objects are inlined at
their use sites rather than aggregated in a top level field of the
response.

Tomasz Zarna

unread,
Aug 5, 2013, 4:32:50 PM8/5/13
to repo-d...@googlegroups.com

Fair enough, thanks for the reply.
 
 
 
Reply all
Reply to author
Forward
0 new messages