gnodet-bot commented on code in PR #30983:
URL: https://github.com/apache/camel/pull/30983#discussion_r4720807980


##########
components/camel-azure/camel-azure-iothub/src/test/java/org/apache/camel/component/azure/iothub/client/DeviceClientPoolTest.java:
##########
@@ -168,6 +168,26 @@ void testRemoveClosesClient() throws Exception {
         verify(client, times(1)).close();
     }
 
+    @Test
+    void testHttpsClientIsKeptApartAndRemovedByDeviceId() throws Exception {
+        DeviceClient https = mock(DeviceClient.class);
+        DeviceClient mqtt = mock(DeviceClient.class);
+        DeviceClientPool pool = new DeviceClientPool(Duration.ofMinutes(5), 
Duration.ofSeconds(30));
+        pool.setDeviceClientFactory((cs, protocol) -> protocol == 
IotHubClientProtocol.HTTPS ? https : mqtt);
+
+        assertSame(https, pool.getOrCreate("d", CS, 
IotHubClientProtocol.HTTPS));
+        assertSame(mqtt, pool.getOrCreate("d", CS, IotHubClientProtocol.MQTT));
+        assertSame(mqtt, pool.getOrCreate("d", CS, 
IotHubClientProtocol.AMQPS));
+        assertEquals(2, pool.getActiveClientCount());
+
+        pool.remove("d");
+        pool.remove("d");

Review Comment:
   Still two `pool.remove("d")` calls needed here because `remove(String 
deviceId)` returns early on the first matching entry. The suggestion from the 
previous review to drop the early `return` and remove all matching entries in 
one pass would let this test call `pool.remove("d")` once — but that is a minor 
nit; the production path `remove(deviceId, connectionString)` correctly removes 
both keys. Feel free to address in a follow-up or leave it as-is if the 
two-call behaviour is intentional documentation.



-- 
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]

Reply via email to