code: private void commitEntries() {
      context.checkThread();
  
      // Sort the list of replicas, order by the last index that was replicated
      // to the replica. This will allow us to determine the median index
      // for all known replicated entries across all cluster members.
      List<MemberState> members = context.getClusterState().getActiveMemberStates((m1, m2) ->
        Long.compare(m2.getMatchIndex() != 0 ? m2.getMatchIndex() : 0L, m1.getMatchIndex() != 0 ? m1.getMatchIndex() : 0L));
  
      // If the active members list is empty (a configuration change occurred between an append request/response)
      // ensure all commit futures are completed and cleared.
      if (members.isEmpty()) {
        long previousCommitIndex = context.getCommitIndex();
        long commitIndex = context.getLog().lastIndex();
        context.setCommitIndex(commitIndex);
        completeCommits(previousCommitIndex, commitIndex);
        return;
      }
  
      // Calculate the current commit index as the median matchIndex.
      long commitIndex = members.get(quorumIndex()).getMatchIndex();
  
      // If the commit index has increased then update the commit index. Note that in order to ensure
      // the leader completeness property holds, we verify that the commit index is greater than or equal to
      // the index of the leader's no-op entry. Update the commit index and trigger commit futures.
      long previousCommitIndex = context.getCommitIndex();
      if (commitIndex > 0 && commitIndex > previousCommitIndex && (leaderIndex > 0 && commitIndex >= leaderIndex)) {
        context.setCommitIndex(commitIndex);
        completeCommits(previousCommitIndex, commitIndex);
      }
    }
docs: Checks whether any futures can be completed.