Cleanup webappconfiguration (#3703)

* Cleanup webappconfiguration
* formatting fix
* cleanup examples and OSGi
* disable classloader test until 9.4.19 is released with #3726 is fixed
* cleanup from review

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-06-05 11:53:56 +02:00 committed by GitHub
parent 885dfed0b7
commit 043521ce26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 75 additions and 49 deletions

View File

@ -9,7 +9,7 @@ org.eclipse.jetty.servlet.WebApplicationContext object
-->
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="warn"><Arg>async-rest webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
<Get name="servletContext">
<Call name="log"><Arg>The async-rest webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
</Configure>

View File

@ -67,6 +67,8 @@ public class TestJettyOSGiBootWithAnnotations
"com.sun.org.apache.xpath.internal.jaxp", "com.sun.org.apache.xpath.internal.objects"));
options.addAll(TestOSGiUtil.coreJettyDependencies());
// TODO uncomment and update the following once 9.4.19 is released with a fix for #3726
// options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-util").version("9.4.19.v????????").noStart());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));

View File

@ -152,7 +152,7 @@ public class FilterMapping implements Dumpable
if (_holder==null)
return false;
if (_dispatches==0)
return type==REQUEST || type==ASYNC && holder.isAsyncSupported();
return type==REQUEST || type==ASYNC && holder.isAsyncSupported();
return (_dispatches&type)!=0;
}

View File

@ -32,14 +32,10 @@ public class WebAppConfiguration extends AbstractConfiguration
addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class);
addDependents(JettyWebXmlConfiguration.class);
protectAndExpose(
"org.eclipse.jetty.util.log.",
"org.eclipse.jetty.server.session.SessionData",
"org.eclipse.jetty.servlet.StatisticsServlet",
"org.eclipse.jetty.servlet.StatisticsServlet",
"org.eclipse.jetty.servlet.DefaultServlet",
"org.eclipse.jetty.servlet.NoJspServlet",
"org.eclipse.jetty.continuation.");
expose( // TODO Evaluate why these are not protectAndExpose?
"org.eclipse.jetty.servlet.listener.",
"org.eclipse.jetty.alpn.");
"org.eclipse.jetty.servlet.NoJspServlet"
);
expose("org.eclipse.jetty.servlet.listener.");
}
}

View File

@ -2,7 +2,7 @@
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="warn"><Arg>test-jaas webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
<Get name="servletContext">
<Call name="log"><Arg>The test-jaas webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
</Configure>

View File

@ -141,6 +141,7 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>

View File

@ -19,7 +19,8 @@ org.eclipse.jetty.servlet.WebApplicationContext object
</Arg>
</Call>
</Get>
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="warn"><Arg>test webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
<Get name="servletContext">
<Call name="log"><Arg>The test-jetty webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
</Configure>

View File

@ -2,7 +2,7 @@
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="warn"><Arg>test-jndi webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
<Get name="servletContext">
<Call name="log"><Arg>The test-jndi webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
</Configure>

View File

@ -2,5 +2,8 @@
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get name="servletContext">
<Call name="log"><Arg>The test-proxy webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
<Set name="contextPath">/proxy</Set>
</Configure>

View File

@ -73,6 +73,7 @@
<instructions>
<Bundle-SymbolicName>org.eclipse.jetty.tests.test-spec-webapp</Bundle-SymbolicName>
<Bundle-Description>Test Webapp for Servlet 3.1 Features</Bundle-Description>
<!-- TODO Add 'org.eclipse.jetty.util;version="[9.4.19,9.4.20)",' below, once 9.4.19 is released with a fix for #3726 -->
<Import-Package>
javax.transaction*;version="[1.1,1.3)",
javax.servlet*;version="[2.6,4.1)",
@ -199,12 +200,6 @@
<artifactId>jakarta.transaction-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-servlet-api</artifactId>
@ -215,21 +210,30 @@
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-web-fragment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-container-initializer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<!-- deliberately old version to test classloading -->
<version>9.3.0.RC0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-web-fragment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-container-initializer</artifactId>
<version>${project.version}</version>
</dependency>
<!-- deliberately old version to test classloading -->
<!-- TODO uncomment and update the following once 9.4.19 is released with a fix for #3726
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.19.vXXXXXXXX</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
</dependencies>
</project>

View File

@ -31,8 +31,6 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.util.IO;
@WebServlet(urlPatterns="/classloader")
public class ClassLoaderServlet extends HttpServlet
{
@ -48,6 +46,8 @@ public class ClassLoaderServlet extends HttpServlet
writer.println("<body>");
writer.println("<h1>ClassLoader Isolation Test</h1>");
// TODO uncomment the following once 9.4.19 is released with a fix for #3726
/*
Class<?> webappIO = IO.class;
URI webappURI = getLocationOfClass(webappIO);
String webappVersion = webappIO.getPackage().getImplementationVersion();
@ -65,6 +65,7 @@ public class ClassLoaderServlet extends HttpServlet
writer.println("<br/><b>URI Result: <span class=\"fail\">FAIL</span></b></p>");
else
writer.println("<br/><b>URI Result: <span class=\"pass\">PASS</span></b></p>");
*/
writer.println("</body>");
writer.println("</html>");

View File

@ -19,6 +19,8 @@
package com.acme.test;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import javax.servlet.ServletConfig;
@ -30,7 +32,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import org.eclipse.jetty.util.IO;
/**
* MultiPartTest
*
@ -58,7 +59,6 @@ public class MultiPartTest extends HttpServlet
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
try
{
response.setContentType("text/html");
@ -78,7 +78,7 @@ public class MultiPartTest extends HttpServlet
if (p.getContentType() == null || p.getContentType().startsWith("text/plain"))
{
out.println("<p>");
IO.copy(p.getInputStream(),out);
copy(p.getInputStream(),out);
out.println("</p>");
}
}
@ -116,8 +116,21 @@ public class MultiPartTest extends HttpServlet
throw new ServletException(e);
}
}
// TODO remove inline once 9.4.19 is released with a fix for #3726
public static void copy(InputStream in,
OutputStream out)
throws IOException
{
int bufferSize = 8192;
byte buffer[] = new byte[bufferSize];
while (true)
{
int len=in.read(buffer,0,bufferSize);
if (len<0 )
break;
out.write(buffer,0,len);
}
}
}

View File

@ -2,7 +2,12 @@
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="warn"><Arg>test-spec webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
<Get name="servletContext">
<Call name="log"><Arg>The test-spec webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
</Get>
<!--TODO uncomment once 9.4.19 is released with a fix for #3726
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
<Call name="info"><Arg>WEB-INF/lib/jetty-util.jar logging used!</Arg></Call>
</Get>
-->
</Configure>