private boolean tryToAbortTx(Throwable e) {
    // According to https://kafka.apache.org/0110/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html
    // We can't recover from these exceptions, so our only option is to close the producer and exit.
    boolean
        isNotFencedOut =
        !(e instanceof ProducerFencedException)
            && !(e instanceof OutOfOrderSequenceException)
            && !(e instanceof AuthenticationException);
    // producer.send() may throw a KafkaException which wraps a FencedException therefore check inner cause.
    boolean causeIsNotFencedOut = !(e.getCause() != null && e.getCause() instanceof ProducerFencedException);
    return isNotFencedOut && causeIsNotFencedOut;
  }
Checks for existing exception. In case of exception will close consumer and rethrow as IOException
@throws IOException abort if possible, close consumer then rethrow exception.
kafka-handler/src/java/org/apache/hadoop/hive/kafka/TransactionalKafkaWriter.java