@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UL_UNRELEASED_LOCK", justification = "This method unlocks and then conditionally undoes the unlock in the finally-block. Review again at later time.") public int entryCount(LocalRegion localRegion) { // if size is the first operation in the transaction, then reset the txState boolean resetTXState = this.realDeal == null; TXStateProxy txp = null; boolean txUnlocked = false; if (resetTXState) { txp = getTxMgr().pauseTransaction(); } else { if (getLock().isHeldByCurrentThread()) { txUnlocked = true; // bug #42945 - hang trying to compute size for PR getLock().unlock(); } } try { if (resetTXState) { return localRegion.getSharedDataView().entryCount(localRegion); } return getRealDeal(null, localRegion).entryCount(localRegion); } finally { if (resetTXState) { getTxMgr().unpauseTransaction(txp); } else if (txUnlocked) { getLock().lock(); } } }
@Before public void setup() { txStateProxy = mock(TXStateProxyImpl.class, RETURNS_DEEP_STUBS); exception = new CommitConflictException(""); transactionDataNodeHasDepartedException = new TransactionDataNodeHasDepartedException(""); executor = mock(SingleThreadJTAExecutor.class); when(txStateProxy.getTxMgr()).thenReturn(mock(TXManagerImpl.class)); }
@Override public Set getBucketKeys(LocalRegion localRegion, int bucketId, boolean allowTombstones) { boolean resetTxState = isTransactionInternalSuspendNeeded(localRegion); TXStateProxy txp = null; if (resetTxState) { txp = getTxMgr().pauseTransaction(); } try { if (resetTxState) { return localRegion.getSharedDataView().getBucketKeys(localRegion, bucketId, false); } return getRealDeal(null, localRegion).getBucketKeys(localRegion, bucketId, false); } finally { if (resetTxState) { getTxMgr().unpauseTransaction(txp); } } }
@Override public Object getEntryForIterator(KeyInfo key, LocalRegion currRgn, boolean rememberReads, boolean allowTombstones) { boolean resetTxState = isTransactionInternalSuspendNeeded(currRgn); TXStateProxy txp = null; if (resetTxState) { txp = getTxMgr().pauseTransaction(); } try { if (resetTxState) { return currRgn.getSharedDataView().getEntry(key, currRgn, allowTombstones); } return getRealDeal(key, currRgn).getEntryForIterator(key, currRgn, rememberReads, allowTombstones); } finally { if (resetTxState) { getTxMgr().unpauseTransaction(txp); } } }
@Override public Object getKeyForIterator(KeyInfo keyInfo, LocalRegion currRgn, boolean rememberReads, boolean allowTombstones) { boolean resetTxState = isTransactionInternalSuspendNeeded(currRgn); TXStateProxy txp = null; if (resetTxState) { txp = getTxMgr().pauseTransaction(); } try { if (resetTxState) { return currRgn.getSharedDataView().getKeyForIterator(keyInfo, currRgn, rememberReads, allowTombstones); } return getRealDeal(keyInfo, currRgn).getKeyForIterator(keyInfo, currRgn, rememberReads, allowTombstones); } finally { if (resetTxState) { getTxMgr().unpauseTransaction(txp); } } }
@Override public Collection<?> getRegionKeysForIteration(LocalRegion currRegion) { if (currRegion.isUsedForPartitionedRegionBucket()) { return currRegion.getRegionKeysForIteration(); } else { boolean resetTxState = isTransactionInternalSuspendNeeded(currRegion); TXStateProxy txp = null; if (resetTxState) { txp = getTxMgr().pauseTransaction(); } try { if (resetTxState) { return currRegion.getSharedDataView().getRegionKeysForIteration(currRegion); } return getRealDeal(null, currRegion).getRegionKeysForIteration(currRegion); } finally { if (resetTxState) { getTxMgr().unpauseTransaction(txp); } } } }