Synchronize AccountLoader#get and #put

These methods are called from ChangeJson which runs formatting in
parallel. Since these methods modify local variables that are not
thread-safe, they need to be synchronized.

Both methods modify distinct variables so that an overall
synchronization is not required.

Change-Id: I328dc1265c3329f2c7ad66fb5946f30ca4e5f3b8
This commit is contained in:
Patrick Hiesel
2018-04-27 08:34:38 +02:00
parent 6dd1299e98
commit a8bae8376d

View File

@@ -69,7 +69,7 @@ public class AccountLoader {
provided = new ArrayList<>();
}
public AccountInfo get(Account.Id id) {
public synchronized AccountInfo get(Account.Id id) {
if (id == null) {
return null;
}
@@ -81,7 +81,7 @@ public class AccountLoader {
return info;
}
public void put(AccountInfo info) {
public synchronized void put(AccountInfo info) {
checkArgument(info._accountId != null, "_accountId field required");
provided.add(info);
}