You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/07/30 08:53:35 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #9224: [FLINK-13226] [connectors / kafka] Fix race condition between transaction commit and produc…

pnowojski commented on a change in pull request #9224: [FLINK-13226] [connectors / kafka] Fix race condition between transaction commit and produc…
URL: https://github.com/apache/flink/pull/9224#discussion_r308602206
 
 

 ##########
 File path: flink-connectors/flink-connector-kafka-0.11/src/test/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducerITCase.java
 ##########
 @@ -101,6 +101,62 @@ public void testResumeTransaction() throws IOException {
 		deleteTestTopic(topicName);
 	}
 
+	@Test(timeout = 30000L)
+	public void testPartitionsForAfterClosed() throws Exception {
+		FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
+		kafkaProducer.close();
+		assertThrows(() -> kafkaProducer.partitionsFor("Topic"), IllegalStateException.class);
+	}
+
+	@Test(timeout = 30000L)
+	public void testInitTransactionsAfterClosed() throws Exception {
+		FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
+		kafkaProducer.close();
+		assertThrows(kafkaProducer::initTransactions, IllegalStateException.class);
+	}
+
+	@Test(timeout = 30000L)
+	public void testBeginTransactionAfterClosed() throws Exception {
+		FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
+		kafkaProducer.initTransactions();
+		kafkaProducer.close();
+		assertThrows(kafkaProducer::beginTransaction, IllegalStateException.class);
 
 Review comment:
   nit: maybe use `org.junit.rules.ExpectedException`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services