Source:
<code>public void shouldCloseActiveTasksDirtyAndPropagateCommitException() { final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl( new Metrics(), "clientId", StreamsConfig.METRICS_LATEST); taskManager = new TaskManager( changeLogReader, UUID.randomUUID(), "taskManagerTest", streamsMetrics, activeTaskCreator, standbyTaskCreator, topologyBuilder, adminClient, stateDirectory, StreamThread.ProcessingMode.EXACTLY_ONCE_ALPHA ); taskManager.setMainConsumer(consumer); final Task task00 = new StateMachineTask(taskId00, taskId00Partitions, true); <START> final StateMachineTask task01 = new StateMachineTask(taskId01, taskId01Partitions, true); <END> final Map<TopicPartition, OffsetAndMetadata> offsets = singletonMap(t1p1, new OffsetAndMetadata(0L, null)); task01.setCommittableOffsetsAndMetadata(offsets); task01.setCommitNeeded(); taskManager.tasks().put(taskId00, task00); taskManager.tasks().put(taskId01, task01); expect(activeTaskCreator.streamsProducerForTask(taskId01)).andThrow(new RuntimeException("task 0_1 producer boom!")); activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(eq(taskId01)); EasyMock.expectLastCall(); replay(activeTaskCreator); final RuntimeException thrown = assertThrows(RuntimeException.class, () -> taskManager.handleAssignment(mkMap(mkEntry(taskId00, taskId00Partitions)), Collections.emptyMap())); assertThat(thrown.getCause().getMessage(), is("task 0_1 producer boom!")); assertThat(task00.state(), is(Task.State.CREATED)); assertThat(task01.state(), is(Task.State.CLOSED)); verify(activeTaskCreator); }</code><technical_language>nit: Task for task00 StateMachineTask for task01 ? unify this (it a confusing)</technical_language>

Target:
public void shouldCloseActiveTasksDirtyAndPropagateCommitException() { final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl( new Metrics(), "clientId", StreamsConfig.METRICS_LATEST); taskManager = new TaskManager( changeLogReader, UUID.randomUUID(), "taskManagerTest", streamsMetrics, activeTaskCreator, standbyTaskCreator, topologyBuilder, adminClient, stateDirectory, StreamThread.ProcessingMode.EXACTLY_ONCE_ALPHA ); taskManager.setMainConsumer(consumer); final Task task00 = new StateMachineTask(taskId00, taskId00Partitions, true); final StateMachineTask task01 = new StateMachineTask(taskId01, taskId01Partitions, true); task01.setCommittableOffsetsAndMetadata(singletonMap(t1p1, new OffsetAndMetadata(0L, null))); task01.setCommitNeeded(); final StateMachineTask task02 = new StateMachineTask(taskId02, taskId02Partitions, true); final Map<TopicPartition, OffsetAndMetadata> offsetsT02 = singletonMap(t1p2, new OffsetAndMetadata(1L, null)); task02.setCommittableOffsetsAndMetadata(offsetsT02); task02.setCommitNeeded(); taskManager.tasks().put(taskId00, task00); taskManager.tasks().put(taskId01, task01); taskManager.tasks().put(taskId02, task02); expect(activeTaskCreator.streamsProducerForTask(taskId01)).andThrow(new RuntimeException("task 0_1 producer boom!")); checkOrder(activeTaskCreator, false); activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(taskId01); expectLastCall(); activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(taskId02); expectLastCall(); replay(activeTaskCreator); final RuntimeException thrown = assertThrows(RuntimeException.class, () -> taskManager.handleAssignment(mkMap(mkEntry(taskId00, taskId00Partitions)), Collections.emptyMap())); assertThat(thrown.getCause().getMessage(), is("task 0_1 producer boom!")); assertThat(task00.state(), is(Task.State.CREATED)); assertThat(task01.state(), is(Task.State.CLOSED)); assertThat(task02.state(), is(Task.State.CLOSED)); verify(activeTaskCreator); }