kenhuuu commented on code in PR #2361:
URL: https://github.com/apache/tinkerpop/pull/2361#discussion_r1403635304


##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java:
##########
@@ -174,8 +175,13 @@ else if (boolean.class.isAssignableFrom(type))
                         else if (String[].class.isAssignableFrom(type)) {
                             arguments[i] = new String[random.nextInt(10) + 1];
                             for (int j = 0; j < ((String[]) 
arguments[i]).length; j++) {
-                                list.add(((String[]) arguments[i])[j] = 
randomString(random));
+                                list.add(((String[]) arguments[i])[j] = 
arguments[0] + randomString(random)); // adds the first string to all to avoid 
duplicates
                             }
+                            // makes sure that no duplicated random string is 
created by removing duplicates
+                            arguments[i] = Arrays.stream((String[]) 
arguments[i]).distinct().toArray(String[]::new);
+                            final Set<Object> tempSet = new 
LinkedHashSet<>(list);
+                            list.clear();
+                            list.addAll(tempSet);

Review Comment:
   This logic seems overly complex. The simplest way to do this would probably 
be to just generate the arguments and ensure they are unique. Then, add that 
unique array to list after.



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