bmhm commented on a change in pull request #240:
URL: https://github.com/apache/shiro/pull/240#discussion_r439936890



##########
File path: 
config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java
##########
@@ -290,7 +293,9 @@ private String parseBeanId(String lhs) {
         }
 
         //SHIRO-413: init method must be called for constructed objects that 
are Initializable
-        LifecycleUtils.init(objects.values());
+        //SHIRO-778: onInit method on AuthenticatingRealm is called twice
+        objects.keySet().stream().filter(key -> 
!Optional.ofNullable(kvPairs).orElseGet(HashMap::new).keySet().contains(key))

Review comment:
       Oh, and of course, instead of calling 
   `Optional.ofNullable(kvPairs).orElseGet(HashMap::new).keySet()`
   when refactoring into it's own line you could also use this:
   `Set knownKeys = 
Optional.ofNullable(kvPairs).map(Map::keySet).orElseGet(Collections::emptySet)`.
   
   I mean, the filter is about the set containing a key, right? Or if you avoid 
mapping into a new collection, you can use containsKey instead: 
   `.filter(key -> !map.containsKey(key))`.
   That's probably even better because it avoids creation of a new collection 
and is even shorter to read and easier to understand on first sight.




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


Reply via email to