bbejeck commented on code in PR #24310:
URL: https://github.com/apache/kafka/pull/24310#discussion_r4647506529
##########
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java:
##########
@@ -376,8 +378,28 @@ public List<PartitionInfo> partitionsFor(final String
topic) {
logContext
);
- setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
- setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ try {
+ setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
+ setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ } catch (final Throwable e) {
+ // the caller gets no driver to close
+ Utils.closeQuietly(() -> closeDirty(e instanceof
TaskCorruptedException), "topology test driver");
+ throw e;
+ }
+ }
+
+ private void closeDirty(final boolean corrupted) throws IOException {
+ if (task != null) {
+ task.suspend();
+ if (corrupted) {
+ // as for a corrupted task in Kafka Streams, so that its state
is wiped with transactional state stores too
+ task.markChangelogAsCorrupted(task.changelogPartitions());
+ }
+ task.closeDirty();
+ }
+ if (globalStateManager != null) {
+ globalStateManager.close();
Review Comment:
If anythign above throws this step will be skipped
--
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]