Merge branch '1.5.x' into 2.0.x

This commit is contained in:
Phillip Webb
2018-08-30 15:59:02 -07:00
7 changed files with 63 additions and 60 deletions

View File

@@ -48,24 +48,8 @@ class NoSuchMethodFailureAnalyzer extends AbstractFailureAnalyzer<NoSuchMethodEr
if (actual == null) {
return null;
}
StringWriter description = new StringWriter();
PrintWriter writer = new PrintWriter(description);
writer.print("An attempt was made to call the method ");
writer.print(cause.getMessage());
writer.print(" but it does not exist. Its class, ");
writer.print(className);
writer.println(", is available from the following locations:");
writer.println();
for (URL candidate : candidates) {
writer.print(" ");
writer.println(candidate);
}
writer.println();
writer.println("It was loaded from the following location:");
writer.println();
writer.print(" ");
writer.println(actual);
return new FailureAnalysis(description.toString(),
String description = getDescription(cause, className, candidates, actual);
return new FailureAnalysis(description,
"Correct the classpath of your application so that it contains a single,"
+ " compatible version of " + className,
cause);
@@ -105,4 +89,26 @@ class NoSuchMethodFailureAnalyzer extends AbstractFailureAnalyzer<NoSuchMethodEr
}
}
private String getDescription(NoSuchMethodError cause, String className,
List<URL> candidates, URL actual) {
StringWriter description = new StringWriter();
PrintWriter writer = new PrintWriter(description);
writer.print("An attempt was made to call the method ");
writer.print(cause.getMessage());
writer.print(" but it does not exist. Its class, ");
writer.print(className);
writer.println(", is available from the following locations:");
writer.println();
for (URL candidate : candidates) {
writer.print(" ");
writer.println(candidate);
}
writer.println();
writer.println("It was loaded from the following location:");
writer.println();
writer.print(" ");
writer.println(actual);
return description.toString();
}
}

View File

@@ -319,8 +319,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
private AccessLogHandler createAccessLogHandler(HttpHandler handler,
AccessLogReceiver accessLogReceiver) {
createAccessLogDirectoryIfNecessary();
String formatString = ((this.accessLogPattern != null) ? this.accessLogPattern
: "common");
String formatString = (this.accessLogPattern != null) ? this.accessLogPattern
: "common";
return new AccessLogHandler(handler, accessLogReceiver, formatString,
Undertow.class.getClassLoader());
}

View File

@@ -196,7 +196,6 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
((ConfigurableWebEnvironment) environment)
.initPropertySources(this.servletContext, null);
}
}
@Override

View File

@@ -30,7 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
/**
* @author awilkinson
* Tests for {@link NoSuchMethodFailureAnalyzer}.
*
* @author Andy Wilkinson
*/
@RunWith(ModifiedClassPathRunner.class)
@ClassPathOverrides("javax.servlet:servlet-api:2.5")