From 95a9e1221f1782705cb42603cdc1ca38bbfc0cce Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 9 May 2018 16:37:45 -0700 Subject: [PATCH] Fix bug in the mockQueryService() method storing the created CqQueries and OQL Indexes in an instance of java.util.concurrent.ConcurrentSkipListSet, which requires the o.a.g.cache.query.Index interface to implement java.lang.Comparable. Fix bug in the mockLuceneIndexFactory() method, setFields(:String[]) method on the o.a.g.cache.lucene.LuceneIndexFactory to properly handle the String array argument. --- .../tests/mock/GemFireMockObjectsSupport.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java b/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java index c2a5782..48dc46a 100644 --- a/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java +++ b/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java @@ -56,7 +56,6 @@ import java.util.Properties; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; @@ -1566,8 +1565,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { QueryService mockQueryService = mock(QueryService.class); - Set cqQueries = new ConcurrentSkipListSet<>(); - Set indexes = new ConcurrentSkipListSet<>(); + Set cqQueries = Collections.synchronizedSet(new HashSet<>()); + Set indexes = Collections.synchronizedSet(new HashSet<>()); try { when(mockQueryService.getCqs()).thenAnswer(invocation -> cqQueries.toArray(new CqQuery[cqQueries.size()])); @@ -1835,10 +1834,14 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { when(mockLuceneIndexFactory.setFields(ArgumentMatchers.any())).thenAnswer(invocation -> { - String[] fieldsArgument = invocation.getArgument(0); + Object[] fieldsArgument = invocation.getArguments(); fields.clear(); - fields.addAll(Arrays.asList(nullSafeArray(fieldsArgument, String.class))); + + Arrays.stream(nullSafeArray(fieldsArgument, Object.class)) + .filter(field -> field instanceof String) + .map(String::valueOf) + .forEach(fields::add); return mockLuceneIndexFactory; });