- if (profiles.isEmpty()) {
- profile = MobileLedgerProfile.loadAllFromDB(profileUUID);
- }
- else {
- try (LockHolder ignored = profiles.lockForReading()) {
+ try (LockHolder readLock = profilesLocker.lockForReading()) {
+ List<MobileLedgerProfile> prList = profiles.getValue();
+ assert prList != null;
+ if (prList.isEmpty()) {
+ readLock.close();
+ try (LockHolder ignored = profilesLocker.lockForWriting()) {
+ profile = MobileLedgerProfile.loadAllFromDB(profileUUID);
+ }
+ }
+ else {