Source:
public void updateAccounts(Collection<Account> accounts) throws AccountServiceException { Objects.requireNonNull(accounts, "accounts cannot be null"); if (accounts.isEmpty()) { throw new IllegalArgumentException("Empty account collection to update."); } if (mySqlAccountStore == null) { throw new AccountServiceException("MySql Account store is not accessible", AccountServiceErrorCode.InternalError); } if (config.updateDisabled) { throw new AccountServiceException("Updates have been disabled", AccountServiceErrorCode.UpdateDisabled); } if (hasDuplicateAccountIdOrName(accounts)) { accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Duplicate account id or name exist in the accounts to update", AccountServiceErrorCode.ResourceConflict); } infoMapLock.readLock().lock(); try { AccountInfoMap accountInfoMap = accountInfoMapRef.get(); if (accountInfoMap.hasConflictingAccount(accounts, true)) { logger.error("Accounts={} conflict with the accounts in local cache. Cancel the update operation.", accounts); accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Input accounts conflict with the accounts in local cache", AccountServiceErrorCode.ResourceConflict); } for (Account account : accounts) { if (accountInfoMap.hasConflictingContainer(account.getAllContainers(), account.getId(), true)) { logger.error( "Containers={} under Account={} conflict with the containers in local cache. Cancel the update operation.", account.getAllContainers(), account.getId()); accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Containers in account " + account.getId() + " conflict with local cache", AccountServiceErrorCode.ResourceConflict); } } } finally { infoMapLock.readLock().unlock(); } try { updateAccountsWithMySqlStore(accounts); } catch (SQLException e) { logger.error("Failed updating accounts={} in MySql DB", accounts, e); handleSQLException(e); } infoMapLock.writeLock().lock(); try { accountInfoMapRef.get().addOrUpdateAccounts(accounts); } finally { infoMapLock.writeLock().unlock(); } }

Target:
public void updateAccounts(Collection<Account> accounts) throws AccountServiceException { Objects.requireNonNull(accounts, "accounts cannot be null"); if (accounts.isEmpty()) { throw new IllegalArgumentException("Empty account collection to update."); } if (mySqlAccountStore == null) { throw new AccountServiceException("MySql Account store is not accessible", AccountServiceErrorCode.InternalError); } if (config.updateDisabled) { throw new AccountServiceException("Updates have been disabled", AccountServiceErrorCode.UpdateDisabled); } if (hasDuplicateAccountIdOrName(accounts)) { accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Duplicate account id or name exist in the accounts to update", AccountServiceErrorCode.ResourceConflict); } infoMapLock.readLock().lock(); try { AccountInfoMap accountInfoMap = accountInfoMapRef.get(); if (accountInfoMap.hasConflictingAccount(accounts, config.ignoreVersionMismatch)) { logger.error("Accounts={} conflict with the accounts in local cache. Cancel the update operation.", accounts); accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Input accounts conflict with the accounts in local cache", AccountServiceErrorCode.ResourceConflict); } for (Account account : accounts) { if (accountInfoMap.hasConflictingContainer(account.getAllContainers(), account.getId(), config.ignoreVersionMismatch)) { logger.error( "Containers={} under Account={} conflict with the containers in local cache. Cancel the update operation.", account.getAllContainers(), account.getId()); accountServiceMetrics.updateAccountErrorCount.inc(); throw new AccountServiceException("Containers in account " + account.getId() + " conflict with local cache", AccountServiceErrorCode.ResourceConflict); } } } finally { infoMapLock.readLock().unlock(); } try { updateAccountsWithMySqlStore(accounts); } catch (SQLException e) { logger.error("Failed updating accounts={} in MySql DB", accounts, e); handleSQLException(e); } infoMapLock.writeLock().lock(); try { accountInfoMapRef.get().addOrUpdateAccounts(accounts); } finally { infoMapLock.writeLock().unlock(); } }