Check for null before trying to use ApplicationContext
Fixes gh-145
This commit is contained in:
@@ -87,6 +87,10 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
|
||||
public void logAutoConfigurationReport(boolean isCrashReport) {
|
||||
if (this.report == null) {
|
||||
if (this.applicationContext == null) {
|
||||
this.logger.info("Nothing to report: ApplicationContext not available");
|
||||
return;
|
||||
}
|
||||
this.report = AutoConfigurationReport.get(this.applicationContext
|
||||
.getBeanFactory());
|
||||
}
|
||||
|
||||
@@ -162,6 +162,13 @@ public class AutoConfigurationReportLoggingInitializerTests {
|
||||
assertNotNull(context.getBean(AutoConfigurationReport.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noErrorIfNotInitialized() throws Exception {
|
||||
this.initializer.handleError(null, null, new String[0], new RuntimeException(
|
||||
"Planned"));
|
||||
assertThat(this.infoLog.get(0), containsString("Nothing to report"));
|
||||
}
|
||||
|
||||
public static class MockLogFactory extends LogFactoryImpl {
|
||||
@Override
|
||||
public Log getInstance(String name) throws LogConfigurationException {
|
||||
|
||||
Reference in New Issue
Block a user