holgerfriedrich commented on code in PR #2629:
URL: https://github.com/apache/karaf/pull/2629#discussion_r3836165809


##########
tooling/utils/src/main/java/org/apache/karaf/tools/utils/SortedProperties.java:
##########
@@ -40,28 +40,13 @@ public Set<Object> keySet() {
 
     @Override
     public Set<Map.Entry<Object, Object>> entrySet() {
-        Set<Map.Entry<Object, Object>> origSet = super.entrySet();
-        Set<Map.Entry<Object, Object>> sortedSet = new 
LinkedHashSet<Map.Entry<Object, Object>>(origSet.size());
-
-        Iterator<Map.Entry<Object, Object>> iterator = 
origSet.stream().sorted(new Comparator<Map.Entry<Object, Object>>() {
-
-            @Override
-            public int compare(java.util.Map.Entry<Object, Object> o1, 
java.util.Map.Entry<Object, Object> o2) {
-                return 
o1.getKey().toString().compareTo(o2.getKey().toString());
-            }
-        }).iterator();
-
-        while (iterator.hasNext())
-            sortedSet.add(iterator.next());
-
-        return sortedSet;
+        return super.entrySet().stream()
+            .sorted(Comparator.comparing(entry -> entry.getKey().toString()))
+            .collect(Collectors.toCollection(LinkedHashSet::new));

Review Comment:
   I am not sure it this actually holds in practice. I'd prefer the simpler 
version of the code.



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