ptupitsyn commented on a change in pull request #6847: IGNITE-12147 Thin 
client: Fixed partitions response for caches with n…
URL: https://github.com/apache/ignite/pull/6847#discussion_r322922314
 
 

 ##########
 File path: 
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/AffinityAwarenessTest.cs
 ##########
 @@ -268,6 +268,32 @@ public void 
CacheGet_RepeatedCall_DoesNotRequestAffinityMapping()
             };
 
             Assert.AreEqual(expectedRequests, requests);
+
+            // Test cache for which affinity awareness is not applicable.
+            var cfg = new CacheClientConfiguration("replicated_cache") 
{CacheMode = CacheMode.Replicated};
+            var cache = Client.CreateCache<int, int>(cfg);
+
+            cache.Put(1, 1);
+            Client.CreateCache<int, int>("repeat-call-test-replicated");
+            ClearLoggers();
+
+            cache.Get(1);
+            cache.Get(1);
+            cache.Get(1);
+
+            requests = null;
+
+            foreach (var logger in _loggers)
+            {
+                var cacheRequestNames = GetCacheRequestNames(logger);
+
+                if (cacheRequestNames.Any())
+                {
+                    requests = cacheRequestNames.ToArray();
 
 Review comment:
   1. `cacheRequestNames` is a lazy `IEnumerable`, calling `Any` then `ToArray` 
causes multiple enumeration, which is an anti-pattern.
   
   2. We overwrite `requests` here, possibly missing some data, which can be 
confusing.
   
   I propose to replace the loop with the following:
   ```
               var reqs = _loggers
                   .Select(l => new {Logger = l, Requests = 
GetCacheRequestNames(l).ToArray()})
                   .Where(r => r.Requests.Length > 0)
                   .ToArray();
               
               Assert.AreEqual(1, reqs.Length);
               Assert.AreEqual(expectedRequests, reqs[0].Requests);
   ```
   
   I think the intent is more obvious this way.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to