Magic behind AccountInfoCache

Sett 30 ganger
Hopp til første uleste melding

Tomasz Zarna

ulest,
1. aug. 2013, 10:20:4701.08.2013
til 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

ulest,
5. aug. 2013, 13:02:3005.08.2013
til 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

ulest,
5. aug. 2013, 16:32:5005.08.2013
til repo-d...@googlegroups.com

Fair enough, thanks for the reply.
 
 
 
Svar alle
Svar til forfatter
Videresend
0 nye meldinger