public static int[] getPartitionsByTopic(
      String topic, org.apache.kafka.clients.producer.Producer producer) {
    // the fetched list is immutable, so we're creating a mutable copy in order to sort it
    List<PartitionInfo> partitionsList = new ArrayList<>(producer.partitionsFor(topic));

    // sort the partitions by partition id to make sure the fetched partition list is the same
    // across subtasks
    partitionsList.sort(Comparator.comparingInt(PartitionInfo::partition));

    return partitionsList.stream().mapToInt(PartitionInfo::partition).toArray();
  }
Errors encountered in the async producer are stored here.
amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/write/hidden/kafka/HiddenKafkaProducer.java