private static void workerTaskConstructor(WorkerTask<?, ?> mock, MockedConstruction.Context context) {
        for (Object argument : context.arguments()) {
            if (argument instanceof AutoCloseable) {
                Utils.closeQuietly((AutoCloseable) argument, "worker task client");
            }
            if (argument instanceof OffsetBackingStore) {
                Utils.closeQuietly(((OffsetBackingStore) argument)::stop, "offset backing store");
            }
        }
    }
This method is called in place of the constructor of WorkerTask subclasses.
All AutoClosable objects (producers, consumers, admin clients, etc.) are closed, as their lifetimes
are managed by the WorkerTask. While the worker task is mocked, it cannot manage the lifetimes itself.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java