Merge remote-tracking branch 'origin/jetty-9.4.x'
This commit is contained in:
commit
04dae709fc
|
@ -63,6 +63,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||||
import org.eclipse.jetty.http.HttpStatus;
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.io.RuntimeIOException;
|
import org.eclipse.jetty.io.RuntimeIOException;
|
||||||
|
import org.eclipse.jetty.server.HttpChannel;
|
||||||
import org.eclipse.jetty.server.HttpConfiguration;
|
import org.eclipse.jetty.server.HttpConfiguration;
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
@ -518,49 +519,52 @@ public class AsyncMiddleManServletTest
|
||||||
@Test
|
@Test
|
||||||
public void testUpstreamTransformationThrowsAfterCommittingProxyRequest() throws Exception
|
public void testUpstreamTransformationThrowsAfterCommittingProxyRequest() throws Exception
|
||||||
{
|
{
|
||||||
startServer(new EchoHttpServlet());
|
try (StacklessLogging scope = new StacklessLogging(HttpChannel.class))
|
||||||
startProxy(new AsyncMiddleManServlet()
|
|
||||||
{
|
{
|
||||||
@Override
|
startServer(new EchoHttpServlet());
|
||||||
protected ContentTransformer newClientRequestContentTransformer(HttpServletRequest clientRequest, Request proxyRequest)
|
startProxy(new AsyncMiddleManServlet()
|
||||||
{
|
{
|
||||||
return new ContentTransformer()
|
@Override
|
||||||
|
protected ContentTransformer newClientRequestContentTransformer(HttpServletRequest clientRequest, Request proxyRequest)
|
||||||
{
|
{
|
||||||
private int count;
|
return new ContentTransformer()
|
||||||
|
|
||||||
@Override
|
|
||||||
public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) throws IOException
|
|
||||||
{
|
{
|
||||||
if (++count < 2)
|
private int count;
|
||||||
output.add(input);
|
|
||||||
else
|
|
||||||
throw new NullPointerException("explicitly_thrown_by_test");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
startClient();
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
@Override
|
||||||
DeferredContentProvider content = new DeferredContentProvider();
|
public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) throws IOException
|
||||||
client.newRequest("localhost", serverConnector.getLocalPort())
|
{
|
||||||
.content(content)
|
if (++count < 2)
|
||||||
.send(new Response.CompleteListener()
|
output.add(input);
|
||||||
|
else
|
||||||
|
throw new NullPointerException("explicitly_thrown_by_test");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
startClient();
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
DeferredContentProvider content = new DeferredContentProvider();
|
||||||
|
client.newRequest("localhost", serverConnector.getLocalPort())
|
||||||
|
.content(content)
|
||||||
|
.send(new Response.CompleteListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onComplete(Result result)
|
||||||
{
|
{
|
||||||
@Override
|
if (result.isSucceeded() && result.getResponse().getStatus() == 502)
|
||||||
public void onComplete(Result result)
|
latch.countDown();
|
||||||
{
|
}
|
||||||
if (result.isSucceeded() && result.getResponse().getStatus() == 502)
|
});
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
content.offer(ByteBuffer.allocate(512));
|
content.offer(ByteBuffer.allocate(512));
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
content.offer(ByteBuffer.allocate(512));
|
content.offer(ByteBuffer.allocate(512));
|
||||||
content.close();
|
content.close();
|
||||||
|
|
||||||
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -791,41 +795,44 @@ public class AsyncMiddleManServletTest
|
||||||
@Test
|
@Test
|
||||||
public void testClientRequestReadFailsOnSecondRead() throws Exception
|
public void testClientRequestReadFailsOnSecondRead() throws Exception
|
||||||
{
|
{
|
||||||
startServer(new EchoHttpServlet());
|
try (StacklessLogging scope = new StacklessLogging(HttpChannel.class))
|
||||||
startProxy(new AsyncMiddleManServlet()
|
|
||||||
{
|
{
|
||||||
private int count;
|
startServer(new EchoHttpServlet());
|
||||||
|
startProxy(new AsyncMiddleManServlet()
|
||||||
@Override
|
|
||||||
protected int readClientRequestContent(ServletInputStream input, byte[] buffer) throws IOException
|
|
||||||
{
|
{
|
||||||
if (++count < 2)
|
private int count;
|
||||||
return super.readClientRequestContent(input, buffer);
|
|
||||||
else
|
|
||||||
throw new IOException("explicitly_thrown_by_test");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
startClient();
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
@Override
|
||||||
DeferredContentProvider content = new DeferredContentProvider();
|
protected int readClientRequestContent(ServletInputStream input, byte[] buffer) throws IOException
|
||||||
client.newRequest("localhost", serverConnector.getLocalPort())
|
|
||||||
.content(content)
|
|
||||||
.send(new Response.CompleteListener()
|
|
||||||
{
|
{
|
||||||
@Override
|
if (++count < 2)
|
||||||
public void onComplete(Result result)
|
return super.readClientRequestContent(input, buffer);
|
||||||
{
|
else
|
||||||
if (result.getResponse().getStatus() == 502)
|
throw new IOException("explicitly_thrown_by_test");
|
||||||
latch.countDown();
|
}
|
||||||
}
|
});
|
||||||
});
|
startClient();
|
||||||
content.offer(ByteBuffer.allocate(512));
|
|
||||||
sleep(1000);
|
|
||||||
content.offer(ByteBuffer.allocate(512));
|
|
||||||
content.close();
|
|
||||||
|
|
||||||
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
DeferredContentProvider content = new DeferredContentProvider();
|
||||||
|
client.newRequest("localhost", serverConnector.getLocalPort())
|
||||||
|
.content(content)
|
||||||
|
.send(new Response.CompleteListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onComplete(Result result)
|
||||||
|
{
|
||||||
|
if (result.getResponse().getStatus() == 502)
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
content.offer(ByteBuffer.allocate(512));
|
||||||
|
sleep(1000);
|
||||||
|
content.offer(ByteBuffer.allocate(512));
|
||||||
|
content.close();
|
||||||
|
|
||||||
|
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -842,7 +842,7 @@ public class HttpInput extends ServletInputStream implements Runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (content==null)
|
else if (content==null)
|
||||||
throw new IllegalStateException();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.channels.SelectionKey;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -50,7 +49,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.eclipse.jetty.http.HttpStatus;
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
|
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
|
||||||
import org.eclipse.jetty.io.ManagedSelector;
|
|
||||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
@ -245,30 +243,6 @@ public class ThreadStarvationTest
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// new Thread(()->{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// TimeUnit.SECONDS.sleep(10);
|
|
||||||
//
|
|
||||||
// ServerConnector conn = _server.getBean(ServerConnector.class);
|
|
||||||
// ManagedSelector ms = conn.getSelectorManager().getBean(ManagedSelector.class);
|
|
||||||
//
|
|
||||||
// Selector sel = ms.getSelector();
|
|
||||||
// sel.keys().stream().map((key)->key.attachment()).forEach(
|
|
||||||
// (attach) -> {
|
|
||||||
// System.out.println(attach);
|
|
||||||
// SocketChannelEndPoint endp = (SocketChannelEndPoint) attach;
|
|
||||||
// SslConnection sslconn = (SslConnection) endp.getConnection();
|
|
||||||
// sslconn.dumpBuffers();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// _server.dump(System.out, "");
|
|
||||||
// }
|
|
||||||
// catch (Throwable ignore)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// }).start();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Future<String>> responses = clientExecutors.invokeAll(clientTasks, 60, TimeUnit.SECONDS);
|
List<Future<String>> responses = clientExecutors.invokeAll(clientTasks, 60, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class StacklessLogging implements AutoCloseable
|
||||||
{
|
{
|
||||||
Logger log = Log.getLogger(clazz);
|
Logger log = Log.getLogger(clazz);
|
||||||
// only operate on loggers that are of type StdErrLog
|
// only operate on loggers that are of type StdErrLog
|
||||||
if (log instanceof StdErrLog)
|
if (log instanceof StdErrLog && !log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
StdErrLog stdErrLog=((StdErrLog)log);
|
StdErrLog stdErrLog=((StdErrLog)log);
|
||||||
if (!stdErrLog.isHideStacks())
|
if (!stdErrLog.isHideStacks())
|
||||||
|
@ -63,7 +63,7 @@ public class StacklessLogging implements AutoCloseable
|
||||||
for (Logger log : logs)
|
for (Logger log : logs)
|
||||||
{
|
{
|
||||||
// only operate on loggers that are of type StdErrLog
|
// only operate on loggers that are of type StdErrLog
|
||||||
if (log instanceof StdErrLog)
|
if (log instanceof StdErrLog && !log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
StdErrLog stdErrLog=((StdErrLog)log);
|
StdErrLog stdErrLog=((StdErrLog)log);
|
||||||
if (!stdErrLog.isHideStacks())
|
if (!stdErrLog.isHideStacks())
|
||||||
|
|
Loading…
Reference in New Issue