anyone can explain for me why copycat do so ,like below , the red part can not garantee thread safety ,which means the log index might be duplicated,
/**
* Applies the given command to the log.
*/
private void applyCommand(CommandRequest request, ServerSessionContext session, CompletableFuture<CommandResponse> future) {
final Command command = request.command();
final long term = context.getTerm();
final long timestamp = System.currentTimeMillis();
final long index;
// Create a CommandEntry and append it to the log.
try (CommandEntry entry = context.getLog().create(CommandEntry.class)) {
entry.setTerm(term)
.setSession(request.session())
.setTimestamp(timestamp)
.setSequence(request.sequence())
.setCommand(command);
index = context.getLog().append(entry);
LOGGER.debug("{} - Appended {} to log at index {}", context.getCluster().member().address(), entry, index);
}