szetszwo commented on PR #1159:
URL: https://github.com/apache/ratis/pull/1159#issuecomment-2401011756

   @133tosakarin , on a second thought, let's change the 
`Preconditions.assertEquals(..)` to throw `IOException`.  `Preconditions` 
usually is for correctness checking.  If `Preconditions` fails, it should 
indicate a bug.
   ```java
   @@ -192,8 +193,12 @@ class SnapshotInstallationHandler {
            //TODO: We should only update State with installed snapshot once 
the request is done.
            state.installSnapshot(request);
    
   -        int idx = nextChunkIndex.getAndIncrement();
   -        Preconditions.assertEquals(snapshotChunkRequest.getRequestIndex(), 
idx, "nextChunkIndex");
   +        final int expectedChunkIndex = nextChunkIndex.getAndIncrement();
   +        if (snapshotChunkRequest.getRequestIndex() != expectedChunkIndex) {
   +          throw new IOException("Unexpected request chunk index: " + 
snapshotChunkRequest.getRequestIndex()
   +              + " (the expected index is " + expectedChunkIndex + ")");
   +        }
   +
            // update the committed index
            // re-load the state machine if this is the last chunk
   ```


-- 
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