Source:
public void testLockAfterGet() throws Exception { byte[] rowName = PtBytes.toBytes("1"); Mockery m = new Mockery(); final KeyValueService kvMock = m.mock(KeyValueService.class); final LockService lockMock = m.mock(LockService.class); LockService lock = MultiDelegateProxy.newProxyInstance(LockService.class, lockService, lockMock); final Cell cell = Cell.create(rowName, rowName); timestampService.getFreshTimestamp(); final long startTs = timestampService.getFreshTimestamp(); final long transactionTs = timestampService.getFreshTimestamp(); keyValueService.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY), startTs); m.checking(new Expectations() {{ oneOf(kvMock).get(TABLE, ImmutableMap.of(cell, transactionTs)); will(throwException(new RuntimeException())); never(lockMock).lockWithFullLockResponse(with(LockClient.ANONYMOUS), with(any(LockRequest.class))); }}); SnapshotTransaction snapshot = new SnapshotTransaction(metricsManager, keyValueService, null, transactionService, NoOpCleaner.INSTANCE, () -> transactionTs, ConflictDetectionManagers.createWithNoConflictDetection(), SweepStrategyManagers.createDefault(keyValueService), transactionTs, Optional.empty(), PreCommitConditions.NO_OP, AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING, null, TransactionReadSentinelBehavior.THROW_EXCEPTION, false, timestampCache, AtlasDbConstants.DEFAULT_TRANSACTION_LOCK_ACQUIRE_TIMEOUT_MS, getRangesExecutor, defaultGetRangesConcurrency, MultiTableSweepQueueWriter.NO_OP, deleteExecutor); try { snapshot.get(TABLE, ImmutableSet.of(cell)); fail(); } catch (RuntimeException e) { } m.assertIsSatisfied(); }

Target:
public void testLockAfterGet() throws Exception { byte[] rowName = PtBytes.toBytes("1"); Mockery m = new Mockery(); m.setThreadingPolicy(new Synchroniser()); final KeyValueService kvMock = m.mock(KeyValueService.class); final LockService lockMock = m.mock(LockService.class); LockService lock = MultiDelegateProxy.newProxyInstance(LockService.class, lockService, lockMock); final Cell cell = Cell.create(rowName, rowName); timestampService.getFreshTimestamp(); final long startTs = timestampService.getFreshTimestamp(); final long transactionTs = timestampService.getFreshTimestamp(); keyValueService.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY), startTs); m.checking(new Expectations() {{ oneOf(kvMock).get(TABLE, ImmutableMap.of(cell, transactionTs)); will(throwException(new RuntimeException())); never(lockMock).lockWithFullLockResponse(with(LockClient.ANONYMOUS), with(any(LockRequest.class))); }}); SnapshotTransaction snapshot = new SnapshotTransaction(metricsManager, kvMock, new LegacyTimelockService(timestampService, lock, lockClient), transactionService, NoOpCleaner.INSTANCE, () -> transactionTs, ConflictDetectionManagers.create(keyValueService), SweepStrategyManagers.createDefault(keyValueService), transactionTs, Optional.empty(), PreCommitConditions.NO_OP, AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING, null, TransactionReadSentinelBehavior.THROW_EXCEPTION, false, timestampCache, AtlasDbConstants.DEFAULT_TRANSACTION_LOCK_ACQUIRE_TIMEOUT_MS, getRangesExecutor, defaultGetRangesConcurrency, MultiTableSweepQueueWriter.NO_OP, MoreExecutors.newDirectExecutorService()); try { snapshot.get(TABLE, ImmutableSet.of(cell)); fail(); } catch (RuntimeException e) { } m.assertIsSatisfied(); }