xjrk58 commented on code in PR #24310:
URL: https://github.com/apache/kafka/pull/24310#discussion_r4676975133
##########
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java:
##########
@@ -376,8 +376,38 @@ 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
+ closeDirty(e);
+ throw e;
+ }
+ }
+
+ private void closeDirty(final Throwable cause) {
+ if (task != null) {
+ closeAndSuppress(task::suspend, cause);
+ closeAndSuppress(task::closeDirty, cause);
+ }
+ if (globalStateManager != null) {
+ closeAndSuppress(globalStateManager::close, cause);
+ }
+ // as close() does, so that no state is left behind, whatever made the
construction fail
+ closeAndSuppress(stateDirectory::clean, cause);
Review Comment:
Now it should close only what it opened.
--
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]