Source:
<code>public void testDrivingConnectedStateStoreInDifferentProcessorsTopology() { final String storeName = "connectedStore"; final StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.inMemoryKeyValueStore(storeName), Serdes.String(), Serdes.String()); topology .addSource("source1", STRING_DESERIALIZER, STRING_DESERIALIZER, INPUT_TOPIC_1) .addSource("source2", STRING_DESERIALIZER, STRING_DESERIALIZER, INPUT_TOPIC_2) .addProcessor("processor1", defineWithStores(new StatefulProcessor(storeName), Collections.singleton(storeBuilder)), "source1") <START> .addProcessor("processor2", defineWithStores(new StatefulProcessor(storeName), Collections.singleton(storeBuilder)), "source2") <END> .addSink("counts", OUTPUT_TOPIC_1, "processor1", "processor2"); driver = new TopologyTestDriver(topology, props); driver.pipeInput(recordFactory.create(INPUT_TOPIC_1, "key1", "value1")); driver.pipeInput(recordFactory.create(INPUT_TOPIC_1, "key2", "value2")); driver.pipeInput(recordFactory.create(INPUT_TOPIC_2, "key3", "value3")); driver.pipeInput(recordFactory.create(INPUT_TOPIC_2, "key1", "value4")); assertNoOutputRecord(OUTPUT_TOPIC_1); assertNoOutputRecord(OUTPUT_TOPIC_1); final KeyValueStore<String, String> store = driver.getKeyValueStore("connectedStore"); assertEquals("value4", store.get("key1")); assertEquals("value2", store.get("key2")); assertEquals("value3", store.get("key3")); assertNull(store.get("key4")); }</code><technical_language>Well, get() of returned supplier called multiple times, thus, return name object is passed defineWithStores time -- this is incorrect though, time get() is called a new object returned</technical_language>

Target:
public void testDrivingConnectedStateStoreInDifferentProcessorsTopology() { final String storeName = "connectedStore"; final StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.inMemoryKeyValueStore(storeName), Serdes.String(), Serdes.String()); topology .addSource("source1", STRING_DESERIALIZER, STRING_DESERIALIZER, INPUT_TOPIC_1) .addSource("source2", STRING_DESERIALIZER, STRING_DESERIALIZER, INPUT_TOPIC_2) .addProcessor("processor1", defineWithStores(() -> new StatefulProcessor(storeName), Collections.singleton(storeBuilder)), "source1") .addProcessor("processor2", defineWithStores(() -> new StatefulProcessor(storeName), Collections.singleton(storeBuilder)), "source2") .addSink("counts", OUTPUT_TOPIC_1, "processor1", "processor2"); driver = new TopologyTestDriver(topology, props); final TestInputTopic<String, String> inputTopic = driver.createInputTopic(INPUT_TOPIC_1, STRING_SERIALIZER, STRING_SERIALIZER); final TestOutputTopic<Integer, String> outputTopic1 = driver.createOutputTopic(OUTPUT_TOPIC_1, Serdes.Integer().deserializer(), Serdes.String().deserializer()); inputTopic.pipeInput("key1", "value1"); inputTopic.pipeInput("key2", "value2"); inputTopic.pipeInput("key3", "value3"); inputTopic.pipeInput("key1", "value4"); assertTrue(outputTopic1.isEmpty()); final KeyValueStore<String, String> store = driver.getKeyValueStore("connectedStore"); assertEquals("value4", store.get("key1")); assertEquals("value2", store.get("key2")); assertEquals("value3", store.get("key3")); assertNull(store.get("key4")); }