diff --git a/config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java b/config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java index 77a1db6298..713349401d 100644 --- a/config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java +++ b/config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java @@ -271,7 +271,6 @@ private String parseBeanId(String lhs) { public Map buildObjects(Map kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { - BeanConfigurationProcessor processor = new BeanConfigurationProcessor(); for (Map.Entry entry : kvPairs.entrySet()) { @@ -287,10 +286,15 @@ private String parseBeanId(String lhs) { } processor.execute(); - } - //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 -> !kvPairs.keySet().contains(key)) + .forEach(key -> LifecycleUtils.init(objects.get(key))); + } else { + //SHIRO-413: init method must be called for constructed objects that are Initializable + LifecycleUtils.init(objects.values()); + } return objects; }