jaedonP commented on code in PR #7272:
URL: https://github.com/apache/incubator-kie/pull/7272#discussion_r4539662749
##########
kogito-quarkus/addons/persistence/kafka/runtime/src/test/java/org/kie/kogito/persistence/kafka/KafkaProcessInstancesIT.java:
##########
@@ -88,6 +93,21 @@ void start() {
factory = new KafkaProcessInstancesFactory();
factory.setKafkaConfig(singletonMap(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
kafka.getBootstrapServers()));
factory.setStateListener(listener);
+ createTopic();
+ }
+
+ // With Kafka Streams >= 4.2 the global table fails to initialize ("no
partitions available") if its source topic
+ // does not exist yet, so create it before the topology starts.
+ private void createTopic() {
+ String topic = topicName();
+ try (Admin admin =
Admin.create(singletonMap(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
kafka.getBootstrapServers()))) {
+ admin.createTopics(List.of(new NewTopic(topic, 1, (short)
1))).all().get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
Review Comment:
When Future.get() throws InterruptedException, the JVM clears the thread's
interrupt flag. If we catch it and don't set the flag again, the information
that something asked this thread to stop is lost to the code above us (JUnit,
an executor, a timeout), which may check that flag.
Thread.currentThread().interrupt() restores it. It's the standard idiom for
this exception and what Sonar S2142 expects. In this test the practical impact
is small, because fail(...) ends the test right after, and an interrupt during
topic creation is unlikely. I kept it to follow the convention, but I can drop
it if you prefer.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]