Merge branch '2.0.x' into 2.1.x
This commit is contained in:
commit
ad489baaa3
|
@ -102,9 +102,15 @@
|
|||
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
|
||||
<jdom2.version>2.0.6</jdom2.version>
|
||||
<jedis.version>2.9.1</jedis.version>
|
||||
<<<<<<< HEAD
|
||||
<jersey.version>2.27</jersey.version>
|
||||
<jest.version>6.3.1</jest.version>
|
||||
<jetty.version>9.4.12.v20180830</jetty.version>
|
||||
=======
|
||||
<jersey.version>2.26</jersey.version>
|
||||
<jest.version>5.3.4</jest.version>
|
||||
<jetty.version>9.4.14.v20181114</jetty.version>
|
||||
>>>>>>> 2.0.x
|
||||
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
|
||||
<jetty-el.version>8.5.35.1</jetty-el.version>
|
||||
<jetty-reactive-httpclient.version>1.0.2</jetty-reactive-httpclient.version>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.web.embedded.jetty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.BindException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -145,8 +146,9 @@ public class JettyWebServer implements WebServer {
|
|||
try {
|
||||
connector.start();
|
||||
}
|
||||
catch (BindException ex) {
|
||||
if (connector instanceof NetworkConnector) {
|
||||
catch (IOException ex) {
|
||||
if (connector instanceof NetworkConnector
|
||||
&& findBindException(ex) != null) {
|
||||
throw new PortInUseException(
|
||||
((NetworkConnector) connector).getPort());
|
||||
}
|
||||
|
@ -168,6 +170,16 @@ public class JettyWebServer implements WebServer {
|
|||
}
|
||||
}
|
||||
|
||||
private BindException findBindException(Throwable ex) {
|
||||
if (ex == null) {
|
||||
return null;
|
||||
}
|
||||
if (ex instanceof BindException) {
|
||||
return (BindException) ex;
|
||||
}
|
||||
return findBindException(ex.getCause());
|
||||
}
|
||||
|
||||
private String getActualPortsDescription() {
|
||||
StringBuilder ports = new StringBuilder();
|
||||
for (Connector connector : this.server.getConnectors()) {
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.web.embedded.jetty;
|
|||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
@ -50,54 +49,35 @@ public class ServletContextInitializerConfiguration extends AbstractConfiguratio
|
|||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception {
|
||||
context.addBean(new Initializer(context), true);
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(context.getClassLoader());
|
||||
try {
|
||||
callInitializers(context);
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Jetty {@link AbstractLifeCycle} to call the {@link ServletContextInitializer
|
||||
* ServletContextInitializers}.
|
||||
*/
|
||||
private class Initializer extends AbstractLifeCycle {
|
||||
|
||||
private final WebAppContext context;
|
||||
|
||||
Initializer(WebAppContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception {
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(this.context.getClassLoader());
|
||||
try {
|
||||
callInitializers();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
private void callInitializers(WebAppContext context) throws ServletException {
|
||||
try {
|
||||
setExtendedListenerTypes(context, true);
|
||||
for (ServletContextInitializer initializer : this.initializers) {
|
||||
initializer.onStartup(context.getServletContext());
|
||||
}
|
||||
}
|
||||
|
||||
private void callInitializers() throws ServletException {
|
||||
try {
|
||||
setExtendedListenerTypes(true);
|
||||
for (ServletContextInitializer initializer : ServletContextInitializerConfiguration.this.initializers) {
|
||||
initializer.onStartup(this.context.getServletContext());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
setExtendedListenerTypes(false);
|
||||
}
|
||||
finally {
|
||||
setExtendedListenerTypes(context, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setExtendedListenerTypes(boolean extended) {
|
||||
try {
|
||||
this.context.getServletContext().setExtendedListenerTypes(extended);
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
// Not available on Jetty 8
|
||||
}
|
||||
private void setExtendedListenerTypes(WebAppContext context, boolean extended) {
|
||||
try {
|
||||
context.getServletContext().setExtendedListenerTypes(extended);
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
// Not available on Jetty 8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue