Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-07-15 07:09:18 +0000
committerGreg Wilkins2015-07-15 07:09:18 +0000
commitdeba2f0d6af1a5a4a97c14464f22375a292bc362 (patch)
tree6701ceb015ffba549892b47dc0a19b35090ffec5
parentc2615d5fbd4b08ab6ffe7932a6cb29580d89586d (diff)
downloadorg.eclipse.jetty.project-deba2f0d6af1a5a4a97c14464f22375a292bc362.tar.gz
org.eclipse.jetty.project-deba2f0d6af1a5a4a97c14464f22375a292bc362.tar.xz
org.eclipse.jetty.project-deba2f0d6af1a5a4a97c14464f22375a292bc362.zip
472621 - Unjustified timeout when serving static content
Created HttpConfiguration.setBlockingTimeout as a new timeout to apply to the total read/write operation. Default is -1, which is no overall timeout and only the idle timeout will apply.
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java9
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java29
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java5
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java27
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java9
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java35
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java259
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java5
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java2
9 files changed, 365 insertions, 15 deletions
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java
index 2cf0357f06..52f7b4c83f 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java
@@ -92,7 +92,14 @@ public abstract class AbstractConnection implements Connection
@Override
public void run()
{
- callback.failed(x);
+ try
+ {
+ callback.failed(x);
+ }
+ catch(Exception e)
+ {
+ LOG.warn(e);
+ }
}
});
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
index fcc6a8a83b..b5132876da 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
@@ -56,6 +56,7 @@ public class HttpConfiguration
private int _responseHeaderSize=8*1024;
private int _headerCacheSize=512;
private int _securePort;
+ private long _blockingTimeout=-1;
private String _secureScheme = HttpScheme.HTTPS.asString();
private boolean _sendServerVersion = true;
private boolean _sendXPoweredBy = false;
@@ -111,6 +112,7 @@ public class HttpConfiguration
_sendDateHeader=config._sendDateHeader;
_sendServerVersion=config._sendServerVersion;
_headerCacheSize=config._headerCacheSize;
+ _blockingTimeout=config._blockingTimeout;
}
/* ------------------------------------------------------------ */
@@ -198,6 +200,33 @@ public class HttpConfiguration
}
/* ------------------------------------------------------------ */
+ /** Get the timeout applied to blocking operations.
+ * <p>This timeout is in addition to the {@link Connector#getIdleTimeout()}, and applies
+ * to the total operation (as opposed to the idle timeout that applies to the time no
+ * data is being sent).
+ * @return -1, for no blocking timeout (default), 0 for a blocking timeout equal to the
+ * idle timeout; >0 for a timeout in ms applied to the total blocking operation.
+ */
+ @ManagedAttribute("Timeout in MS for blocking operations.")
+ public long getBlockingTimeout()
+ {
+ return _blockingTimeout;
+ }
+
+ /**
+ * Set the timeout applied to blocking operations.
+ * <p>This timeout is in addition to the {@link Connector#getIdleTimeout()}, and applies
+ * to the total operation (as opposed to the idle timeout that applies to the time no
+ * data is being sent).
+ * @param blockingTimeout -1, for no blocking timeout (default), 0 for a blocking timeout equal to the
+ * idle timeout; >0 for a timeout in ms applied to the total blocking operation.
+ */
+ public void setBlockingTimeout(long blockingTimeout)
+ {
+ _blockingTimeout = blockingTimeout;
+ }
+
+ /* ------------------------------------------------------------ */
public void setPersistentConnectionsEnabled(boolean persistentConnectionsEnabled)
{
_persistentConnectionsEnabled = persistentConnectionsEnabled;
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
index b9f79a292a..9ab2da7e11 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
@@ -783,6 +783,11 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
{
getEndPoint().fillInterested(_blockingReadCallback);
}
+
+ public void blockingReadException(Throwable e)
+ {
+ _blockingReadCallback.failed(e);
+ }
@Override
public String toString()
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
index 031bb10c0f..564e1eebc3 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.ByteBuffer;
import java.util.Objects;
+import java.util.concurrent.TimeoutException;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
@@ -54,10 +55,13 @@ public class HttpInput extends ServletInputStream implements Runnable
private ReadListener _listener;
private State _state = STREAM;
private long _contentConsumed;
+ private long _blockingTimeoutAt = -1;
public HttpInput(HttpChannelState state)
{
_channelState=state;
+ if (_channelState.getHttpChannel().getHttpConfiguration().getBlockingTimeout()>0)
+ _blockingTimeoutAt=0;
}
protected HttpChannelState getHttpChannelState()
@@ -131,6 +135,9 @@ public class HttpInput extends ServletInputStream implements Runnable
{
synchronized (_inputQ)
{
+ if (_blockingTimeoutAt>=0 && !isAsync())
+ _blockingTimeoutAt=System.currentTimeMillis()+getHttpChannelState().getHttpChannel().getHttpConfiguration().getBlockingTimeout();
+
while(true)
{
Content item = nextContent();
@@ -337,11 +344,25 @@ public class HttpInput extends ServletInputStream implements Runnable
{
try
{
+ long timeout=0;
+ if (_blockingTimeoutAt>=0)
+ {
+ timeout=_blockingTimeoutAt-System.currentTimeMillis();
+ if (timeout<=0)
+ throw new TimeoutException();
+ }
+
if (LOG.isDebugEnabled())
- LOG.debug("{} blocking for content...", this);
- _inputQ.wait();
+ LOG.debug("{} blocking for content timeout={} ...", this,timeout);
+ if (timeout>0)
+ _inputQ.wait(timeout);
+ else
+ _inputQ.wait();
+
+ if (_blockingTimeoutAt>0 && System.currentTimeMillis()>=_blockingTimeoutAt)
+ throw new TimeoutException();
}
- catch (InterruptedException e)
+ catch (Throwable e)
{
throw (IOException)new InterruptedIOException().initCause(e);
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java
index df8fbd5b53..f8f718f0d9 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java
@@ -37,6 +37,13 @@ public class HttpInputOverHTTP extends HttpInput
protected void blockForContent() throws IOException
{
((HttpConnection)getHttpChannelState().getHttpChannel().getEndPoint().getConnection()).blockingReadFillInterested();
- super.blockForContent();
+ try
+ {
+ super.blockForContent();
+ }
+ catch(Throwable e)
+ {
+ ((HttpConnection)getHttpChannelState().getHttpChannel().getEndPoint().getConnection()).blockingReadException(e);
+ }
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
index 940ea3f7fc..c16257bb36 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
@@ -98,6 +98,11 @@ public class HttpOutput extends ServletOutputStream implements Runnable
@Override
protected long getIdleTimeout()
{
+ long bto = getHttpChannel().getHttpConfiguration().getBlockingTimeout();
+ if (bto>0)
+ return bto;
+ if (bto<0)
+ return -1;
return _channel.getIdleTimeout();
}
};
@@ -585,6 +590,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
*/
public void sendContent(ByteBuffer content) throws IOException
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent({})",BufferUtil.toDetailString(content));
+
write(content, true);
closed();
}
@@ -662,6 +670,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
*/
public void sendContent(ByteBuffer content, final Callback callback)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent(buffer={},{})",BufferUtil.toDetailString(content),callback);
+
write(content, true, new Callback()
{
@Override
@@ -689,6 +700,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
*/
public void sendContent(InputStream in, Callback callback)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent(stream={},{})",in,callback);
+
new InputStreamWritingCB(in, callback).iterate();
}
@@ -701,6 +715,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
*/
public void sendContent(ReadableByteChannel in, Callback callback)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent(channel={},{})",in,callback);
+
new ReadableByteChannelWritingCB(in, callback).iterate();
}
@@ -712,6 +729,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
*/
public void sendContent(HttpContent httpContent, Callback callback)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent(http={},{})",httpContent,callback);
+
if (BufferUtil.hasContent(_aggregate))
{
callback.failed(new IOException("cannot sendContent() after write()"));
@@ -752,9 +772,6 @@ public class HttpOutput extends ServletOutputStream implements Runnable
if (buffer!=null)
{
- if (LOG.isDebugEnabled())
- LOG.debug("sendContent({}=={},{},direct={})",httpContent,BufferUtil.toDetailString(buffer),callback,_channel.useDirectBuffers());
-
sendContent(buffer,callback);
return;
}
@@ -764,8 +781,6 @@ public class HttpOutput extends ServletOutputStream implements Runnable
ReadableByteChannel rbc=httpContent.getReadableByteChannel();
if (rbc!=null)
{
- if (LOG.isDebugEnabled())
- LOG.debug("sendContent({}=={},{},direct={})",httpContent,rbc,callback,_channel.useDirectBuffers());
// Close of the rbc is done by the async sendContent
sendContent(rbc,callback);
return;
@@ -774,8 +789,6 @@ public class HttpOutput extends ServletOutputStream implements Runnable
InputStream in = httpContent.getInputStream();
if (in!=null)
{
- if (LOG.isDebugEnabled())
- LOG.debug("sendContent({}=={},{},direct={})",httpContent,in,callback,_channel.useDirectBuffers());
sendContent(in,callback);
return;
}
@@ -1102,6 +1115,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
return Action.SCHEDULED;
}
+ if (LOG.isDebugEnabled() && _completed)
+ LOG.debug("EOF of {}",this);
return Action.SUCCEEDED;
}
@@ -1142,6 +1157,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
// a write done with EOF=true
if (_eof)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("EOF of {}",this);
// Handle EOF
_in.close();
closed();
@@ -1206,6 +1223,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
// a write done with EOF=true
if (_eof)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("EOF of {}",this);
_in.close();
closed();
_channel.getByteBufferPool().release(_buffer);
@@ -1220,7 +1239,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
// write what we have
_buffer.flip();
write(_buffer,_eof,this);
-
+
return Action.SCHEDULED;
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
index a5646ae59a..5edff8a143 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
@@ -18,11 +18,17 @@
package org.eclipse.jetty.server;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.concurrent.Exchanger;
import java.util.concurrent.TimeUnit;
@@ -31,14 +37,18 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.StdErrLog;
import org.hamcrest.Matchers;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -59,6 +69,13 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
System.setProperty("org.eclipse.jetty.io.nio.IDLE_TICK","100");
}
+ @Before
+ public void before()
+ {
+ super.before();
+ if (_httpConfiguration!=null)
+ _httpConfiguration.setBlockingTimeout(-1L);
+ }
@Test(timeout=60000)
public void testMaxIdleWithRequest10() throws Exception
@@ -351,6 +368,227 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
}
@Test(timeout=60000)
+ public void testNoBlockingTimeoutRead() throws Exception
+ {
+ _httpConfiguration.setBlockingTimeout(-1L);
+
+ configureServer(new EchoHandler());
+ Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
+ client.setSoTimeout(10000);
+ InputStream is=client.getInputStream();
+ Assert.assertFalse(client.isClosed());
+
+ OutputStream os=client.getOutputStream();
+ os.write(("GET / HTTP/1.1\r\n"+
+ "host: "+_serverURI.getHost()+":"+_serverURI.getPort()+"\r\n"+
+ "Transfer-Encoding: chunked\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "Connection: close\r\n" +
+ "\r\n"+
+ "5\r\n"+
+ "LMNOP\r\n")
+ .getBytes("utf-8"));
+ os.flush();
+
+ long start = System.currentTimeMillis();
+ try
+ {
+ Thread.sleep(250);
+ os.write("1".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(250);
+ os.write("0".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(250);
+ os.write("\r".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(250);
+ os.write("\n".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(250);
+ os.write("0123456789ABCDEF\r\n".getBytes("utf-8"));
+ os.write("0\r\n".getBytes("utf-8"));
+ os.write("\r\n".getBytes("utf-8"));
+ os.flush();
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ long duration=System.currentTimeMillis() - start;
+ Assert.assertThat(duration,Matchers.greaterThan(500L));
+
+ // read the response
+ String response = IO.toString(is);
+ Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 200 OK"));
+ Assert.assertThat(response,Matchers.containsString("LMNOP0123456789ABCDEF"));
+
+ }
+
+ @Test(timeout=60000)
+ public void testBlockingTimeoutRead() throws Exception
+ {
+ _httpConfiguration.setBlockingTimeout(750L);
+
+ configureServer(new EchoHandler());
+ Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
+ client.setSoTimeout(10000);
+ InputStream is=client.getInputStream();
+ Assert.assertFalse(client.isClosed());
+
+ OutputStream os=client.getOutputStream();
+ os.write(("GET / HTTP/1.1\r\n"+
+ "host: "+_serverURI.getHost()+":"+_serverURI.getPort()+"\r\n"+
+ "Transfer-Encoding: chunked\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "Connection: close\r\n" +
+ "\r\n"+
+ "5\r\n"+
+ "LMNOP\r\n")
+ .getBytes("utf-8"));
+ os.flush();
+
+ long start = System.currentTimeMillis();
+ try
+ {
+ ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true);
+ Thread.sleep(300);
+ os.write("1".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(300);
+ os.write("0".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(300);
+ os.write("\r".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(300);
+ os.write("\n".getBytes("utf-8"));
+ os.flush();
+ Thread.sleep(300);
+ os.write("0123456789ABCDEF\r\n".getBytes("utf-8"));
+ os.write("0\r\n".getBytes("utf-8"));
+ os.write("\r\n".getBytes("utf-8"));
+ os.flush();
+ }
+ catch(Exception e)
+ {
+ }
+ finally
+ {
+ ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false);
+ }
+ long duration=System.currentTimeMillis() - start;
+ Assert.assertThat(duration,Matchers.greaterThan(500L));
+
+ try
+ {
+ // read the response
+ String response = IO.toString(is);
+ Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 500 "));
+ Assert.assertThat(response,Matchers.containsString("InterruptedIOException"));
+ }
+ catch(SSLException e)
+ {
+ }
+
+ }
+
+ @Test(timeout=60000)
+ public void testNoBlockingTimeoutWrite() throws Exception
+ {
+ configureServer(new HugeResponseHandler());
+ Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
+ client.setSoTimeout(10000);
+
+ Assert.assertFalse(client.isClosed());
+
+ OutputStream os=client.getOutputStream();
+ BufferedReader is=new BufferedReader(new InputStreamReader(client.getInputStream(),StandardCharsets.ISO_8859_1),2048);
+
+ os.write((
+ "GET / HTTP/1.0\r\n"+
+ "host: "+_serverURI.getHost()+":"+_serverURI.getPort()+"\r\n"+
+ "connection: keep-alive\r\n"+
+ "Connection: close\r\n"+
+ "\r\n").getBytes("utf-8"));
+ os.flush();
+
+ // read the header
+ String line=is.readLine();
+ Assert.assertThat(line,Matchers.startsWith("HTTP/1.1 200 OK"));
+ while(line.length()!=0)
+ line=is.readLine();
+
+ for (int i=0;i<(128*1024);i++)
+ {
+ if (i%1028==0)
+ {
+ Thread.sleep(20);
+ // System.err.println("read "+System.currentTimeMillis());
+ }
+ line=is.readLine();
+ Assert.assertThat(line,Matchers.notNullValue());
+ Assert.assertEquals(1022,line.length());
+ }
+ }
+
+ @Test(timeout=60000)
+ public void testBlockingTimeoutWrite() throws Exception
+ {
+ _httpConfiguration.setBlockingTimeout(750L);
+ configureServer(new HugeResponseHandler());
+ Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
+ client.setSoTimeout(10000);
+
+ Assert.assertFalse(client.isClosed());
+
+ OutputStream os=client.getOutputStream();
+ BufferedReader is=new BufferedReader(new InputStreamReader(client.getInputStream(),StandardCharsets.ISO_8859_1),2048);
+
+ os.write((
+ "GET / HTTP/1.0\r\n"+
+ "host: "+_serverURI.getHost()+":"+_serverURI.getPort()+"\r\n"+
+ "connection: keep-alive\r\n"+
+ "Connection: close\r\n"+
+ "\r\n").getBytes("utf-8"));
+ os.flush();
+
+ // read the header
+ String line=is.readLine();
+ Assert.assertThat(line,Matchers.startsWith("HTTP/1.1 200 OK"));
+ while(line.length()!=0)
+ line=is.readLine();
+
+ long start=System.currentTimeMillis();
+ try
+ {
+ ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger(AbstractConnection.class)).setHideStacks(true);
+ for (int i=0;i<(128*1024);i++)
+ {
+ if (i%1028==0)
+ {
+ Thread.sleep(20);
+ // System.err.println("read "+System.currentTimeMillis());
+ }
+ line=is.readLine();
+ if (line==null)
+ break;
+ }
+ }
+ catch(Throwable e)
+ {}
+ finally
+ {
+ ((StdErrLog)Log.getLogger(AbstractConnection.class)).setHideStacks(false);
+ ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false);
+ }
+ long end=System.currentTimeMillis();
+ long duration = end-start;
+ Assert.assertThat(duration,Matchers.lessThan(20L*128L));
+ }
+
+ @Test(timeout=60000)
public void testMaxIdleNoRequest() throws Exception
{
configureServer(new EchoHandler());
@@ -522,6 +760,27 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
out.close();
}
}
+
+ protected static class HugeResponseHandler extends AbstractHandler
+ {
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ baseRequest.setHandled(true);
+ response.setStatus(200);
+ OutputStream out = response.getOutputStream();
+ byte[] buffer = new byte[128*1024*1024];
+ Arrays.fill(buffer,(byte)'x');
+ for (int i=0;i<128*1024;i++)
+ {
+ buffer[i*1024+1022]='\r';
+ buffer[i*1024+1023]='\n';
+ }
+ ByteBuffer bb = ByteBuffer.wrap(buffer);
+ ((HttpOutput)out).sendContent(bb);
+ out.close();
+ }
+ }
protected static class WaitHandler extends AbstractHandler
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java
index 12a0c3a1ca..06def0cc90 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java
@@ -49,6 +49,7 @@ public class HttpServerTestFixture
protected QueuedThreadPool _threadPool;
protected Server _server;
protected URI _serverURI;
+ protected HttpConfiguration _httpConfiguration;
protected ServerConnector _connector;
protected String _scheme="http";
@@ -76,7 +77,9 @@ public class HttpServerTestFixture
protected void startServer(ServerConnector connector, Handler handler) throws Exception
{
_connector = connector;
- _connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
+ _httpConfiguration=_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
+ _httpConfiguration.setBlockingTimeout(-1);
+ _httpConfiguration.setSendDateHeader(false);
_server.addConnector(_connector);
_server.setHandler(handler);
_server.start();
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java
index 35e7ee064f..71c10ac62a 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java
@@ -126,7 +126,7 @@ public class PathResource extends Resource
}
catch (IOException e)
{
- // Ignore
+ LOG.ignore(e);
}
catch (Exception e)
{

Back to the top