Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/47#discussion_r138270921 --- Diff: tephra-core/src/main/java/org/apache/tephra/TransactionManager.java --- @@ -853,46 +867,45 @@ private void advanceWritePointer(long writePointer) { } } - public boolean canCommit(Transaction tx, Collection<byte[]> changeIds) - throws TransactionNotInProgressException, TransactionSizeException { + public void canCommit(long txId, Collection<byte[]> changeIds) + throws TransactionNotInProgressException, TransactionSizeException, TransactionConflictException { txMetricsCollector.rate("canCommit"); Stopwatch timer = new Stopwatch().start(); - InProgressTx inProgressTx = inProgress.get(tx.getTransactionId()); + InProgressTx inProgressTx = inProgress.get(txId); if (inProgressTx == null) { synchronized (this) { // invalid transaction, either this has timed out and moved to invalid, or something else is wrong. - if (invalidTxList.contains(tx.getTransactionId())) { + if (invalidTxList.contains(txId)) { throw new TransactionNotInProgressException( String.format( - "canCommit() is called for transaction %d that is not in progress (it is known to be invalid)", - tx.getTransactionId())); + "canCommit() is called for transaction %d that is not in progress (it is known to be invalid)", txId)); } else { throw new TransactionNotInProgressException( - String.format("canCommit() is called for transaction %d that is not in progress", tx.getTransactionId())); + String.format("canCommit() is called for transaction %d that is not in progress", txId)); } } } Set<ChangeId> set = - validateChangeSet(tx, changeIds, inProgressTx.clientId != null ? inProgressTx.clientId : DEFAULT_CLIENTID); - - if (hasConflicts(tx, set)) { - return false; + validateChangeSet(txId, changeIds, inProgressTx.clientId != null ? inProgressTx.clientId : DEFAULT_CLIENTID); + for (byte[] change : changeIds) { --- End diff -- I don't think this for-loop is needed as method `validateChangeSet()` already returns `Set<ChangeId>`.
---