Skip to content

Commit 03585f2

Browse files
committed
Reduced warn log entry without stacktrace for startup exceptions
Also, AbstractApplicationContext.isRunning avoids IllegalStateException now. Issue: SPR-13663 Issue: SPR-13667 (cherry picked from commit 5d6aab3)
1 parent 8d7d4ce commit 03585f2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -483,7 +483,10 @@ public void refresh() throws BeansException, IllegalStateException {
483483
}
484484

485485
catch (BeansException ex) {
486-
logger.warn("Exception encountered during context initialization - cancelling refresh attempt", ex);
486+
if (logger.isWarnEnabled()) {
487+
logger.warn("Exception encountered during context initialization - " +
488+
"cancelling refresh attempt: " + ex);
489+
}
487490

488491
// Destroy already created singletons to avoid dangling resources.
489492
destroyBeans();
@@ -884,11 +887,12 @@ protected void registerListeners() {
884887
for (ApplicationListener<?> listener : getApplicationListeners()) {
885888
getApplicationEventMulticaster().addApplicationListener(listener);
886889
}
890+
887891
// Do not initialize FactoryBeans here: We need to leave all regular beans
888892
// uninitialized to let post-processors apply to them!
889893
String[] listenerBeanNames = getBeanNamesForType(ApplicationListener.class, true, false);
890-
for (String lisName : listenerBeanNames) {
891-
getApplicationEventMulticaster().addApplicationListenerBean(lisName);
894+
for (String listenerBeanName : listenerBeanNames) {
895+
getApplicationEventMulticaster().addApplicationListenerBean(listenerBeanName);
892896
}
893897
}
894898

@@ -1287,7 +1291,7 @@ public void stop() {
12871291
}
12881292

12891293
public boolean isRunning() {
1290-
return getLifecycleProcessor().isRunning();
1294+
return (this.lifecycleProcessor != null && this.lifecycleProcessor.isRunning());
12911295
}
12921296

12931297

0 commit comments

Comments
 (0)