Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Greg Wilkins 2018-08-15 11:58:52 +10:00
commit 9ff37122db
4 changed files with 101 additions and 2 deletions

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
public class OneHandler public class OneHandler

View File

@ -574,6 +574,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
} }
try try
if (cause instanceof BadMessageException)
{ {
_state.onError(failure); _state.onError(failure);
} }
@ -596,12 +597,29 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
_response.setStatus(code == null ? 500 : code); _response.setStatus(code == null ? 500 : code);
_response.flushBuffer(); _response.flushBuffer();
} }
}
catch (Throwable x) catch (Throwable x)
{ {
if (x != failure) if (x != failure)
failure.addSuppressed(x); failure.addSuppressed(x);
abort(failure); abort(failure);
} }
/** Unwrap failure causes to find target class
* @param failure The throwable to have its causes unwrapped
* @param targets Exception classes that we should not unwrap
* @return A target throwable or null
*/
protected Throwable unwrap(Throwable failure, Class<?> ... targets)
{
while (failure!=null)
{
for (Class<?> x : targets)
if (x.isInstance(failure))
return failure;
failure = failure.getCause();
}
return null;
} }
public boolean isExpecting100Continue() public boolean isExpecting100Continue()

View File

@ -27,6 +27,8 @@ import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -87,7 +89,33 @@ public class ErrorHandlerTest
super.generateAcceptableResponse(baseRequest,request,response,code,message,mimeType); super.generateAcceptableResponse(baseRequest,request,response,code,message,mimeType);
} }
} }
});
server.setHandler(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
if (baseRequest.getDispatcherType()==DispatcherType.ERROR)
{
baseRequest.setHandled(true);
response.sendError(((Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE)).intValue());
return;
}
if(target.startsWith("/charencoding/"))
{
baseRequest.setHandled(true);
response.setCharacterEncoding("utf-8");
response.sendError(404);
return;
}
if(target.startsWith("/badmessage/"))
{
throw new ServletException(new BadMessageException(Integer.valueOf(target.substring(12))));
}
}
}); });
server.setHandler(new AbstractHandler() server.setHandler(new AbstractHandler()
{ {

54
pom.xml
View File

@ -1373,6 +1373,60 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
<profile>
<id>eclipse-sign</id>
<activation>
<property>
<name>eclipse-sign</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pack200a-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>pack200-normalize</id>
<goals>
<goal>normalize</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.cbi.maven.plugins</groupId>
<artifactId>eclipse-jarsigner-plugin</artifactId>
<version>${cbi-plugins.version}</version>
<executions>
<execution>
<id>sign</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pack200b-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>pack200-pack</id>
<goals>
<goal>pack</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>8u00</id> <id>8u00</id>
<activation> <activation>