Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
Closes gh-23135
  • Loading branch information
philwebb committed Aug 28, 2020
2 parents bc1834b + 38db582 commit 84f281f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.context.logging;

import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -53,7 +54,6 @@
import org.springframework.core.log.LogMessage;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;

/**
Expand Down Expand Up @@ -307,13 +307,17 @@ private void initializeSystem(ConfigurableEnvironment environment, LoggingSystem
}
else {
try {
ResourceUtils.getURL(logConfig).openStream().close();
system.initialize(initializationContext, logConfig, logFile);
}
catch (Exception ex) {
Throwable exceptionToReport = ex;
while (exceptionToReport != null && !(exceptionToReport instanceof FileNotFoundException)) {
exceptionToReport = exceptionToReport.getCause();
}
exceptionToReport = (exceptionToReport != null) ? exceptionToReport : ex;
// NOTE: We can't use the logger here to report the problem
System.err.println("Logging system failed to initialize using configuration from '" + logConfig + "'");
ex.printStackTrace(System.err);
exceptionToReport.printStackTrace(System.err);
throw new IllegalStateException(ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ void overrideConfigDoesNotExist() {
addPropertiesToEnvironment(this.context, "logging.config=doesnotexist.xml");
assertThatIllegalStateException().isThrownBy(() -> {
this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader());
assertThat(this.output)
.contains("Logging system failed to initialize using configuration from 'doesnotexist.xml'");
});
assertThat(this.output)
.contains("Logging system failed to initialize using configuration from 'doesnotexist.xml'")
.doesNotContain("JoranException");
}

@Test
Expand Down

0 comments on commit 84f281f

Please sign in to comment.