Skip to content

Commit

Permalink
Proposed fix for issue jetty#705.
Browse files Browse the repository at this point in the history
Use regular class loading for default configuration instance
creation.
  • Loading branch information
jerboaa committed Jul 13, 2016
1 parent 92b0be6 commit 79e0390
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public interface Configuration


public class ClassList extends ArrayList<String>
{
{
/* ------------------------------------------------------------ */
/** Get/Set/Create the server default Configuration ClassList.
* <p>Get the class list from: a Server bean; or the attribute (which can
Expand Down Expand Up @@ -140,12 +140,7 @@ public static ClassList serverDefault(Server server)
if (attr instanceof String[])
return new ClassList((String[])attr);
}
return new ClassList();
}

public ClassList()
{
this(WebAppContext.DEFAULT_CONFIGURATION_CLASSES);
return new DefaultClassList();
}

public ClassList(String[] classes)
Expand Down Expand Up @@ -198,4 +193,11 @@ public void addBefore(@Name("beforeClass") String beforeClass,@Name("configClass
}

}

class DefaultClassList extends ClassList {

private DefaultClassList() {
super(WebAppContext.DEFAULT_CONFIGURATION_CLASSES);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.Configuration.ClassList;
import org.eclipse.jetty.webapp.Configuration.DefaultClassList;

/**
* Web Application Context Handler.
Expand Down Expand Up @@ -100,11 +102,20 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL

public static final String[] DEFAULT_CONFIGURATION_CLASSES =
{
"org.eclipse.jetty.webapp.WebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
"org.eclipse.jetty.webapp.WebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
} ;

public static final Configuration[] DEFAULT_CONFIGURATIONS =
{
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new JettyWebXmlConfiguration()
} ;

// System classes are classes that cannot be replaced by
Expand Down Expand Up @@ -925,8 +936,16 @@ protected void loadConfigurations()
if (_configurations.size()>0)
return;

if (_configurationClasses.size()==0)
_configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer()));
if (_configurationClasses.size()==0) {
ClassList serverDefault = Configuration.ClassList.serverDefault(getServer());
if (serverDefault instanceof DefaultClassList) {
_configurationClasses.addAll(serverDefault);
_configurations.addAll(Arrays.asList(DEFAULT_CONFIGURATIONS));
return;
} else {
_configurationClasses.addAll(serverDefault);
}
}
for (String configClass : _configurationClasses)
_configurations.add((Configuration)Loader.loadClass(configClass).newInstance());
}
Expand Down

0 comments on commit 79e0390

Please sign in to comment.