mjsax commented on code in PR #16988:
URL: https://github.com/apache/kafka/pull/16988#discussion_r1757680374
##########
streams/src/test/java/org/apache/kafka/streams/integration/QueryableStateIntegrationTest.java:
##########
@@ -1085,77 +1086,72 @@ public void shouldAllowToQueryAfterThreadDied() throws
Exception {
final StreamsBuilder builder = new StreamsBuilder();
final KStream<String, String> input = builder.stream(streamOne);
input
- .groupByKey()
- .reduce((value1, value2) -> {
- if (value1.length() > 1) {
- if (beforeFailure.compareAndSet(true, false)) {
- throw new RuntimeException("Injected test exception");
+ .groupByKey()
+ .reduce((value1, value2) -> {
+ if (value1.length() > 1) {
+ if (beforeFailure.compareAndSet(true, false)) {
+ throw new RuntimeException("Injected test
exception");
+ }
}
- }
- return value1 + value2;
- }, Materialized.as(storeName))
- .toStream()
- .to(outputTopic);
+ return value1 + value2;
+ }, Materialized.as(storeName))
+ .toStream()
+ .to(outputTopic);
streamsConfiguration.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 2);
kafkaStreams = new KafkaStreams(builder.build(), streamsConfiguration);
- kafkaStreams.setUncaughtExceptionHandler((t, e) -> failed.set(true));
+ kafkaStreams.setUncaughtExceptionHandler(exception -> REPLACE_THREAD);
startApplicationAndWaitUntilRunning(kafkaStreams);
IntegrationTestUtils.produceKeyValuesSynchronously(
- streamOne,
- Arrays.asList(
- KeyValue.pair("a", "1"),
- KeyValue.pair("a", "2"),
- KeyValue.pair("b", "3"),
- KeyValue.pair("b", "4")),
- TestUtils.producerConfig(
- CLUSTER.bootstrapServers(),
- StringSerializer.class,
- StringSerializer.class,
- new Properties()),
- mockTime);
+ streamOne,
+ Arrays.asList(
+ KeyValue.pair("a", "1"),
+ KeyValue.pair("a", "2"),
+ KeyValue.pair("b", "3"),
+ KeyValue.pair("b", "4")),
+ TestUtils.producerConfig(
+ CLUSTER.bootstrapServers(),
+ StringSerializer.class,
+ StringSerializer.class,
+ new Properties()),
+ mockTime);
final int maxWaitMs = 30000;
final ReadOnlyKeyValueStore<String, String> store =
- IntegrationTestUtils.getStore(storeName, kafkaStreams,
keyValueStore());
+ IntegrationTestUtils.getStore(storeName, kafkaStreams,
keyValueStore());
TestUtils.waitForCondition(
- () -> "12".equals(store.get("a")) && "34".equals(store.get("b")),
- maxWaitMs,
- "wait for agg to be <a,12> and <b,34>");
+ () -> "12".equals(store.get("a")) &&
"34".equals(store.get("b")),
+ maxWaitMs,
+ "wait for agg to be <a,12> and <b,34>");
IntegrationTestUtils.produceKeyValuesSynchronously(
- streamOne,
- Collections.singleton(KeyValue.pair("a", "5")),
- TestUtils.producerConfig(
- CLUSTER.bootstrapServers(),
- StringSerializer.class,
- StringSerializer.class,
- new Properties()),
- mockTime);
-
- TestUtils.waitForCondition(
Review Comment:
Well, I think we need to keep the `failed` flag, and also set it in the new
handler (cf my other comment above). Otherwise, we modify the test what we
don't want to do.
--
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]