From ed7708d56a4adf5e680014580e9968bc2053eef9 Mon Sep 17 00:00:00 2001 From: Eran Landau Date: Wed, 17 Aug 2016 11:32:24 -0700 Subject: [PATCH] Fix incorrect warnings --- .../guice/ConfigurationInjectingListener.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/archaius2-guice/src/main/java/com/netflix/archaius/guice/ConfigurationInjectingListener.java b/archaius2-guice/src/main/java/com/netflix/archaius/guice/ConfigurationInjectingListener.java index 6cf2bd3e8..aed5d99be 100644 --- a/archaius2-guice/src/main/java/com/netflix/archaius/guice/ConfigurationInjectingListener.java +++ b/archaius2-guice/src/main/java/com/netflix/archaius/guice/ConfigurationInjectingListener.java @@ -53,11 +53,6 @@ CascadeStrategy getCascadeStrategy() { @Override public void onProvision(ProvisionInvocation provision) { - if (injector == null) { - LOG.warn("Can't inject configuration until ConfigurationInjectingListener has been initialized"); - return; - } - Class clazz = provision.getBinding().getKey().getTypeLiteral().getRawType(); // @@ -65,6 +60,11 @@ public void onProvision(ProvisionInvocation provision) { // final ConfigurationSource source = clazz.getDeclaredAnnotation(ConfigurationSource.class); if (source != null) { + if (injector == null) { + LOG.warn("Can't inject configuration into {} until ConfigurationInjectingListener has been initialized", clazz.getName()); + return; + } + CascadeStrategy strategy = source.cascading() != ConfigurationSource.NullCascadeStrategy.class ? injector.getInstance(source.cascading()) : getCascadeStrategy(); @@ -87,6 +87,11 @@ public void onProvision(ProvisionInvocation provision) { // Configuration configAnnot = clazz.getAnnotation(Configuration.class); if (configAnnot != null) { + if (injector == null) { + LOG.warn("Can't inject configuration into {} until ConfigurationInjectingListener has been initialized", clazz.getName()); + return; + } + try { mapper.mapConfig(provision.provision(), config, new IoCContainer() { @Override