Forgotten modifications from Jetty7
This commit is contained in:
parent
5624a5721e
commit
fef74963af
|
@ -14,7 +14,6 @@
|
|||
package org.eclipse.jetty.continuation;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletRequestWrapper;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
@ -36,7 +35,7 @@ public class ContinuationSupport
|
|||
static
|
||||
{
|
||||
boolean servlet3Support=false;
|
||||
Constructor<?>s3cc=null;
|
||||
Constructor<? extends Continuation>s3cc=null;
|
||||
try
|
||||
{
|
||||
boolean servlet3=ServletRequest.class.getMethod("startAsync")!=null;
|
||||
|
@ -52,11 +51,11 @@ public class ContinuationSupport
|
|||
finally
|
||||
{
|
||||
__servlet3=servlet3Support;
|
||||
__newServlet3Continuation=(Constructor<? extends Continuation>)s3cc;
|
||||
__newServlet3Continuation=s3cc;
|
||||
}
|
||||
|
||||
|
||||
boolean jetty6Support=false;
|
||||
Constructor<?>j6cc=null;
|
||||
Constructor<? extends Continuation>j6cc=null;
|
||||
try
|
||||
{
|
||||
Class<?> jetty6ContinuationClass = ContinuationSupport.class.getClassLoader().loadClass("org.mortbay.util.ajax.Continuation");
|
||||
|
@ -73,9 +72,9 @@ public class ContinuationSupport
|
|||
finally
|
||||
{
|
||||
__jetty6=jetty6Support;
|
||||
__newJetty6Continuation=(Constructor<? extends Continuation>)j6cc;
|
||||
__newJetty6Continuation=j6cc;
|
||||
}
|
||||
|
||||
|
||||
Class<?> waiting=null;
|
||||
try
|
||||
{
|
||||
|
@ -93,12 +92,12 @@ public class ContinuationSupport
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Get a Continuation. The type of the Continuation returned may
|
||||
* vary depending on the container in which the application is
|
||||
* vary depending on the container in which the application is
|
||||
* deployed. It may be an implementation native to the container (eg
|
||||
* org.eclipse.jetty.server.AsyncContinuation) or one of the utility
|
||||
* implementations provided such as an internal <code>FauxContinuation</code>
|
||||
* or a real implementation like {@link org.eclipse.jetty.continuation.Servlet3Continuation}.
|
||||
* @param request The request
|
||||
* @param request The request
|
||||
* @return a Continuation instance
|
||||
*/
|
||||
public static Continuation getContinuation(ServletRequest request)
|
||||
|
@ -106,10 +105,10 @@ public class ContinuationSupport
|
|||
Continuation continuation = (Continuation) request.getAttribute(Continuation.ATTRIBUTE);
|
||||
if (continuation!=null)
|
||||
return continuation;
|
||||
|
||||
|
||||
while (request instanceof ServletRequestWrapper)
|
||||
request=((ServletRequestWrapper)request).getRequest();
|
||||
|
||||
|
||||
if (__servlet3 )
|
||||
{
|
||||
try
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.eclipse.jetty.continuation;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -16,7 +15,7 @@ import javax.servlet.ServletResponseWrapper;
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This implementation of Continuation is used by {@link ContinuationSupport}
|
||||
* when it detects that the application has been deployed in a non-jetty Servlet 3
|
||||
* when it detects that the application has been deployed in a non-jetty Servlet 3
|
||||
* server.
|
||||
*/
|
||||
public class Servlet3Continuation implements Continuation
|
||||
|
@ -24,11 +23,11 @@ public class Servlet3Continuation implements Continuation
|
|||
// Exception reused for all continuations
|
||||
// Turn on debug in ContinuationFilter to see real stack trace.
|
||||
private final static ContinuationThrowable __exception = new ContinuationThrowable();
|
||||
|
||||
|
||||
private final ServletRequest _request;
|
||||
private ServletResponse _response;
|
||||
private AsyncContext _context;
|
||||
private List<AsyncListener> _listeners=new ArrayList<AsyncListener>();
|
||||
private List<AsyncListener> _listeners=new ArrayList<AsyncListener>();
|
||||
private volatile boolean _initial=true;
|
||||
private volatile boolean _resumed=false;
|
||||
private volatile boolean _expired=false;
|
||||
|
@ -59,7 +58,6 @@ public class Servlet3Continuation implements Continuation
|
|||
public void onTimeout(AsyncEvent event) throws IOException
|
||||
{
|
||||
_initial=false;
|
||||
System.err.println("Doing dispatch on timed out continuation for "+_request.getAttribute("FOO"));
|
||||
event.getAsyncContext().dispatch();
|
||||
}
|
||||
});
|
||||
|
@ -91,7 +89,7 @@ public class Servlet3Continuation implements Continuation
|
|||
listener.onTimeout(Servlet3Continuation.this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (_context!=null)
|
||||
_context.addListener(wrapped);
|
||||
else
|
||||
|
@ -171,7 +169,7 @@ public class Servlet3Continuation implements Continuation
|
|||
_expired=false;
|
||||
_context=_request.startAsync();
|
||||
_context.setTimeout(_timeoutMs);
|
||||
|
||||
|
||||
for (AsyncListener listener:_listeners)
|
||||
_context.addListener(listener);
|
||||
_listeners.clear();
|
||||
|
@ -184,7 +182,7 @@ public class Servlet3Continuation implements Continuation
|
|||
_expired=false;
|
||||
_context=_request.startAsync();
|
||||
_context.setTimeout(_timeoutMs);
|
||||
|
||||
|
||||
for (AsyncListener listener:_listeners)
|
||||
_context.addListener(listener);
|
||||
_listeners.clear();
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -28,6 +25,9 @@ import org.eclipse.jetty.io.SimpleBuffers;
|
|||
import org.eclipse.jetty.io.View;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class HttpGeneratorClientTest
|
||||
{
|
||||
public final static String CONTENT="The quick brown fox jumped over the lazy dog.\nNow is the time for all good men to come to the aid of the party\nThe moon is blue to a fish in love.\n";
|
||||
|
@ -52,7 +52,7 @@ public class HttpGeneratorClientTest
|
|||
|
||||
generator.completeHeader(fields,false);
|
||||
|
||||
generator.addContent(new ByteArrayBuffer(content),true);
|
||||
generator.addContent(new ByteArrayBuffer(content).asMutableBuffer(),true);
|
||||
generator.flushBuffer();
|
||||
generator.complete();
|
||||
generator.flushBuffer();
|
||||
|
@ -77,7 +77,7 @@ public class HttpGeneratorClientTest
|
|||
|
||||
String content = "The quick brown fox jumped over the lazy dog";
|
||||
|
||||
generator.addContent(new ByteArrayBuffer(content),true);
|
||||
generator.addContent(new ByteArrayBuffer(content).asMutableBuffer(),true);
|
||||
generator.completeHeader(fields,true);
|
||||
|
||||
generator.flushBuffer();
|
||||
|
@ -106,7 +106,7 @@ public class HttpGeneratorClientTest
|
|||
|
||||
generator.completeHeader(fields,false);
|
||||
|
||||
generator.addContent(new ByteArrayBuffer(content),false);
|
||||
generator.addContent(new ByteArrayBuffer(content).asMutableBuffer(),false);
|
||||
generator.flushBuffer();
|
||||
generator.complete();
|
||||
generator.flushBuffer();
|
||||
|
@ -120,7 +120,7 @@ public class HttpGeneratorClientTest
|
|||
* screw up the chunking by leaving out the second chunk header.
|
||||
*/
|
||||
@Test
|
||||
public void testChunkedWithBackPressure() throws Exception
|
||||
public void testChunkedWithBackPressure() throws Exception
|
||||
{
|
||||
final AtomicInteger availableChannelBytes = new AtomicInteger(500);
|
||||
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096)
|
||||
|
|
|
@ -352,7 +352,8 @@ public class ByteArrayBuffer extends AbstractBuffer
|
|||
throws IOException
|
||||
{
|
||||
out.write(_bytes,getIndex(),length());
|
||||
clear();
|
||||
if (!isImmutable())
|
||||
clear();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -246,7 +246,8 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
}
|
||||
}
|
||||
int len = _out.put(buffer);
|
||||
buffer.skip(len);
|
||||
if (!buffer.isImmutable())
|
||||
buffer.skip(len);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,8 @@ public class StreamEndPoint implements EndPoint
|
|||
int length=buffer.length();
|
||||
if (length>0)
|
||||
buffer.writeTo(_out);
|
||||
buffer.clear();
|
||||
if (!buffer.isImmutable())
|
||||
buffer.clear();
|
||||
return length;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue