amaliujia commented on code in PR #1696:
URL: https://github.com/apache/ratis/pull/1696#discussion_r4601643675


##########
ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreStateMachine.java:
##########
@@ -150,12 +150,8 @@ public TransactionContext 
startTransaction(RaftClientRequest request) throws IOE
 
   @Override
   public TransactionContext startTransaction(LogEntryProto entry, 
RaftProtos.RaftPeerRole role) {
-    return TransactionContext.newBuilder()
-        .setStateMachine(this)
-        .setLogEntry(entry)
-        .setServerRole(role)
-        .setStateMachineContext(getProto(entry))
-        .build();
+    final TransactionContext trx = super.startTransaction(entry, role);
+    return trx.setStateMachineContext(getProto(entry));

Review Comment:
   Thanks for reporting this. The real issue then is inside the builder 
actually. So we should fix there directly at 
https://github.com/apache/ratis/blob/42115034344246459ff49420504e87b24fac4be5/ratis-server-api/src/main/java/org/apache/ratis/statemachine/TransactionContext.java#L200:
   
   ```Java
   } else {
     Objects.requireNonNull(logEntry, "logEntry must not be null since 
clientRequest == null");
     Preconditions.assertTrue(logEntry.hasStateMachineLogEntry(),
         () -> "Unexpected logEntry: stateMachineLogEntry not found, logEntry=" 
+ logEntry);
     return newTransactionContext(serverRole, stateMachine, logEntry)
         .setStateMachineContext(stateMachineContext);
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to