Merge branch 'jetty-9.3.x'

This commit is contained in:
Greg Wilkins 2016-04-08 18:19:53 +10:00
commit d2b818c8bb
2 changed files with 19 additions and 32 deletions

View File

@ -77,40 +77,25 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
jetty=web_inf.addPath("web-jetty.xml");
if(jetty.exists())
{
// No server classes while configuring
String[] old_server_classes = context.getServerClasses();
{
if(LOG.isDebugEnabled())
LOG.debug("Configure: "+jetty);
Object xml_attr=context.getAttribute(XML_CONFIGURATION);
context.removeAttribute(XML_CONFIGURATION);
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration
?(XmlConfiguration)xml_attr
:new XmlConfiguration(jetty.getURI().toURL());
setupXmlConfiguration(jetty_config, web_inf);
try
{
context.setServerClasses(null);
if(LOG.isDebugEnabled())
LOG.debug("Configure: "+jetty);
XmlConfiguration jetty_config = (XmlConfiguration)context.getAttribute(XML_CONFIGURATION);
if (jetty_config==null)
{
jetty_config=new XmlConfiguration(jetty.getURI().toURL());
}
else
{
context.removeAttribute(XML_CONFIGURATION);
}
setupXmlConfiguration(jetty_config, web_inf);
try
{
XmlConfiguration config=jetty_config;
WebAppClassLoader.runWithServerClassAccess(()->{config.configure(context);return null;});
}
catch (ClassNotFoundException e)
{
LOG.warn("Unable to process jetty-web.xml", e);
}
WebAppClassLoader.runWithServerClassAccess(()->{jetty_config.configure(context);return null;});
}
finally
catch(Exception e)
{
if (old_server_classes != null)
context.setServerClasses(old_server_classes);
LOG.warn("Error applying {}",jetty);
throw e;
}
}
}

View File

@ -24,6 +24,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -34,6 +35,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration.Dynamic;
@ -186,7 +188,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
private boolean _configurationDiscovered=true;
private boolean _allowDuplicateFragmentNames = false;
private boolean _throwUnavailableOnStartupException = false;
private MetaData _metadata=new MetaData();
@ -748,7 +750,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
_systemClasses.prependPattern(classOrPackage);
}
/* ------------------------------------------------------------ */
@Override
public boolean isServerClass(String name)