3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 18:55:52 +00:00

Wallet: take key chain lock not only wallet lock in getWatchedOutputs().

Flagged by the IntelliJ Inspector static analysis engine.
This commit is contained in:
Mike Hearn 2015-07-28 20:59:03 +02:00
parent b7c24c6196
commit d753d28ba5

View File

@ -2600,6 +2600,7 @@ public class Wallet extends BaseTaggableObject implements BlockChainListener, Pe
*/ */
public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) { public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) {
lock.lock(); lock.lock();
keychainLock.lock();
try { try {
LinkedList<TransactionOutput> candidates = Lists.newLinkedList(); LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) { for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) {
@ -2617,6 +2618,7 @@ public class Wallet extends BaseTaggableObject implements BlockChainListener, Pe
} }
return candidates; return candidates;
} finally { } finally {
keychainLock.unlock();
lock.unlock(); lock.unlock();
} }
} }