Merged branch 'jetty-9' into jetty-9-client.

This commit is contained in:
Simone Bordet 2012-09-06 08:41:48 +02:00
commit 7231c82b69
213 changed files with 3333 additions and 1169 deletions

View File

@ -41,7 +41,6 @@ public class ManyConnectors
SelectChannelConnector connector1 = new SelectChannelConnector(server);
connector1.setHost("127.0.0.1");
connector1.setPort(8888);
connector1.setName("admin");
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
System.setProperty("jetty.home", jetty_home);

View File

@ -34,7 +34,7 @@ import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.GzipHandler;
import org.eclipse.jetty.servlets.gzip.GzipHandler;
import org.eclipse.jetty.util.IO;
import org.junit.After;
import org.junit.Before;

View File

@ -0,0 +1,3 @@
OPTIONS=annotations
etc/jetty-annotations.xml

View File

@ -15,18 +15,10 @@
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Arg name="threadPool">
<!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="maxThreads">200</Set>
<Set name="minThreads">10</Set>
</New>
<!-- Optional Java 5 bounded threadpool with job queue
<New class="org.eclipse.thread.concurrent.ThreadPool">
<Set name="corePoolSize">50</Set>
<Set name="maximumPoolSize">50</Set>
</New>
-->
</Arg>
<!-- =========================================================== -->

View File

@ -343,22 +343,24 @@
<version>${project.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jndi</artifactId>

View File

@ -9,7 +9,6 @@ to serve static html files and images.
-->
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Call class="org.eclipse.jetty.util.log.Log" name="debug"><Arg>Configure javadoc.xml</Arg></Call>
<Set name="contextPath">/resources</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/resources/</Set>
<Set name="handler">

View File

@ -9,7 +9,6 @@ to serve static html files and images.
-->
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Call class="org.eclipse.jetty.util.log.Log" name="debug"><Arg>Configure javadoc.xml</Arg></Call>
<Set name="contextPath">/javadoc</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set>
<Set name="handler">

View File

@ -1,8 +1,13 @@
#===========================================================
# Jetty start.jar arguments
# Each line of this file is prepended to the command line
# arguments # of a call to:
# The contents of this file, together with the start.ini
# fragments found in start.d directory are used to build
# the classpath and command line on a call to
# java -jar start.jar [arg...]
#
# Use the following command to see more options
# java -jar start.jar --help
#
#===========================================================
@ -46,7 +51,7 @@
# for a full listing do
# java -jar start.jar --list-options
#-----------------------------------------------------------
OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations
OPTIONS=Server,jsp,resources,websocket,ext,plus
#-----------------------------------------------------------
@ -55,9 +60,7 @@ OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations
# For a full list of available configuration files do
# java -jar start.jar --help
#-----------------------------------------------------------
#etc/jetty-jmx.xml
etc/jetty.xml
etc/jetty-annotations.xml
# etc/jetty-ssl.xml
# etc/jetty-requestlog.xml
etc/jetty-deploy.xml

View File

@ -17,11 +17,6 @@
<artifactId>jetty-io</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -72,7 +72,7 @@ public class HttpParser
private boolean _host;
/* ------------------------------------------------------------------------------- */
private State _state=State.START;
private volatile State _state=State.START;
private HttpMethod _method;
private String _methodString;
private HttpVersion _version;
@ -217,7 +217,7 @@ public class HttpParser
{
_methodString = _method.asString();
buffer.position(buffer.position()+_methodString.length()+1);
_state=State.SPACE1;
setState(State.SPACE1);
return;
}
}
@ -227,7 +227,7 @@ public class HttpParser
if (_version!=null)
{
buffer.position(buffer.position()+_version.asString().length()+1);
_state=State.SPACE1;
setState(State.SPACE1);
return;
}
}
@ -245,7 +245,7 @@ public class HttpParser
{
_string.setLength(0);
_string.append((char)ch);
_state=_requestHandler!=null?State.METHOD:State.RESPONSE_VERSION;
setState(_requestHandler!=null?State.METHOD:State.RESPONSE_VERSION);
return;
}
}
@ -314,7 +314,7 @@ public class HttpParser
HttpMethod method=HttpMethod.CACHE.get(_methodString);
if (method!=null)
_methodString=method.asString();
_state=State.SPACE1;
setState(State.SPACE1);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -335,7 +335,7 @@ public class HttpParser
badMessage(buffer,HttpStatus.BAD_REQUEST_400,"Unknown Version");
return true;
}
_state=State.SPACE1;
setState(State.SPACE1);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -351,12 +351,12 @@ public class HttpParser
{
if (_responseHandler!=null)
{
_state=State.STATUS;
setState(State.STATUS);
_responseStatus=ch-'0';
}
else
{
_state=State.URI;
setState(State.URI);
_utf8.reset();
_utf8.append(ch);
}
@ -371,7 +371,7 @@ public class HttpParser
case STATUS:
if (ch == HttpTokens.SPACE)
{
_state=State.SPACE2;
setState(State.SPACE2);
}
else if (ch>='0' && ch<='9')
{
@ -381,7 +381,7 @@ public class HttpParser
{
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, null);
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
}
else
{
@ -394,7 +394,7 @@ public class HttpParser
{
_uri=_utf8.toString();
_utf8.reset();
_state=State.SPACE2;
setState(State.SPACE2);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -402,7 +402,7 @@ public class HttpParser
_uri=_utf8.toString();
_utf8.reset();
return_from_parse|=_requestHandler.startRequest(_method,_methodString,_uri,null);
_state=State.END;
setState(State.END);
BufferUtil.clear(buffer);
return_from_parse|=_handler.headerComplete();
return_from_parse|=_handler.messageComplete(_contentPosition);
@ -419,11 +419,11 @@ public class HttpParser
if (_responseHandler!=null)
{
_length=1;
_state=State.REASON;
setState(State.REASON);
}
else
{
_state=State.REQUEST_VERSION;
setState(State.REQUEST_VERSION);
// try quick look ahead
if (buffer.position()>0 && buffer.hasArray())
@ -434,7 +434,7 @@ public class HttpParser
_string.setLength(0);
buffer.position(buffer.position()+_version.asString().length()-1);
_eol=buffer.get();
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, _version);
}
}
@ -446,13 +446,13 @@ public class HttpParser
{
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, null);
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
}
else
{
// HTTP/0.9
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, null);
_state=State.END;
setState(State.END);
BufferUtil.clear(buffer);
return_from_parse|=_handler.headerComplete();
return_from_parse|=_handler.messageComplete(_contentPosition);
@ -472,7 +472,7 @@ public class HttpParser
}
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, _version);
continue;
}
@ -487,7 +487,7 @@ public class HttpParser
String reason=takeLengthString();
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, reason);
continue;
}
@ -547,7 +547,7 @@ public class HttpParser
// header value without name - continuation?
_length=-1;
_string.setLength(0);
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
}
@ -673,23 +673,23 @@ public class HttpParser
switch (_endOfContent)
{
case EOF_CONTENT:
_state=State.EOF_CONTENT;
setState(State.EOF_CONTENT);
return_from_parse|=_handler.headerComplete();
break;
case CHUNKED_CONTENT:
_state=State.CHUNKED_CONTENT;
setState(State.CHUNKED_CONTENT);
return_from_parse|=_handler.headerComplete();
break;
case NO_CONTENT:
return_from_parse|=_handler.headerComplete();
_state=State.END;
setState(State.END);
return_from_parse|=_handler.messageComplete(_contentPosition);
break;
default:
_state=State.CONTENT;
setState(State.CONTENT);
return_from_parse|=_handler.headerComplete();
break;
}
@ -705,13 +705,13 @@ public class HttpParser
{
_headerString=_header.asString();
buffer.position(buffer.position()+_headerString.length());
_state=buffer.get(buffer.position()-1)==':'?State.HEADER_VALUE:State.HEADER_NAME;
setState(buffer.get(buffer.position()-1)==':'?State.HEADER_VALUE:State.HEADER_NAME);
break;
}
}
// New header
_state=State.HEADER_NAME;
setState(State.HEADER_NAME);
_string.setLength(0);
_string.append((char)ch);
_length=1;
@ -729,7 +729,7 @@ public class HttpParser
consumeCRLF(ch,buffer);
_headerString=takeLengthString();
_header=HttpHeader.CACHE.get(_headerString);
_state=State.HEADER;
setState(State.HEADER);
break;
@ -739,7 +739,7 @@ public class HttpParser
_headerString=takeLengthString();
_header=HttpHeader.CACHE.get(_headerString);
}
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
@ -758,7 +758,7 @@ public class HttpParser
}
_string.append((char)ch);
_length=_string.length();
_state=State.HEADER_IN_NAME;
setState(State.HEADER_IN_NAME);
}
}
@ -773,7 +773,7 @@ public class HttpParser
_headerString=takeString();
_length=-1;
_header=HttpHeader.CACHE.get(_headerString);
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.COLON:
@ -783,11 +783,11 @@ public class HttpParser
_header=HttpHeader.CACHE.get(_headerString);
}
_length=-1;
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
_state=State.HEADER_NAME;
setState(State.HEADER_NAME);
_string.append((char)ch);
break;
default:
@ -821,7 +821,7 @@ public class HttpParser
_valueString=takeLengthString();
}
}
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
@ -830,7 +830,7 @@ public class HttpParser
{
_string.append((char)ch);
_length=_string.length();
_state=State.HEADER_IN_VALUE;
setState(State.HEADER_IN_VALUE);
}
}
break;
@ -861,12 +861,12 @@ public class HttpParser
}
_length=-1;
}
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
_string.append((char)ch);
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
default:
_string.append((char)ch);
@ -919,7 +919,7 @@ public class HttpParser
case CONTENT:
if (_contentPosition==_contentLength)
{
_state=State.END;
setState(State.END);
if(_handler.messageComplete(_contentPosition))
return true;
}
@ -936,7 +936,7 @@ public class HttpParser
{
String chars = BufferUtil.toDetailString(buffer);
BufferUtil.clear(buffer);
throw new IllegalStateException(this+" Extra data after oshut: "+chars);
throw new IllegalStateException(this+" data when CLOSED: "+chars);
}
BufferUtil.clear(buffer);
}
@ -955,7 +955,7 @@ public class HttpParser
// Handle HEAD response
if (_responseStatus>0 && _headResponse)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentLength))
return true;
}
@ -987,7 +987,7 @@ public class HttpParser
long remaining=_contentLength - _contentPosition;
if (remaining == 0)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
@ -1011,7 +1011,7 @@ public class HttpParser
if(_contentPosition == _contentLength)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
@ -1030,7 +1030,7 @@ public class HttpParser
{
_chunkLength=0;
_chunkPosition=0;
_state=State.CHUNK_SIZE;
setState(State.CHUNK_SIZE);
}
break;
}
@ -1046,15 +1046,15 @@ public class HttpParser
{
if (_eol==HttpTokens.CARRIAGE_RETURN && buffer.hasRemaining() && buffer.get(buffer.position())==HttpTokens.LINE_FEED)
_eol=buffer.get();
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
else
_state=State.CHUNK;
setState(State.CHUNK);
}
else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON)
_state=State.CHUNK_PARAMS;
setState(State.CHUNK_PARAMS);
else if (ch >= '0' && ch <= '9')
_chunkLength=_chunkLength * 16 + (ch - '0');
else if (ch >= 'a' && ch <= 'f')
@ -1076,12 +1076,12 @@ public class HttpParser
{
if (_eol==HttpTokens.CARRIAGE_RETURN && buffer.hasRemaining() && buffer.get(buffer.position())==HttpTokens.LINE_FEED)
_eol=buffer.get();
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
else
_state=State.CHUNK;
setState(State.CHUNK);
}
break;
}
@ -1091,7 +1091,7 @@ public class HttpParser
int remaining=_chunkLength - _chunkPosition;
if (remaining == 0)
{
_state=State.CHUNKED_CONTENT;
setState(State.CHUNKED_CONTENT);
}
else
{
@ -1136,7 +1136,7 @@ public class HttpParser
private void badMessage(ByteBuffer buffer, int status, String reason)
{
BufferUtil.clear(buffer);
_state=State.CLOSED;
setState(State.CLOSED);
_handler.badMessage(status, reason);
}
@ -1151,12 +1151,15 @@ public class HttpParser
break;
case EOF_CONTENT:
_state=State.END;
setState(State.END);
_handler.messageComplete(_contentPosition);
break;
case CLOSED:
break;
default:
_state=State.END;
setState(State.END);
if (!_headResponse)
_handler.earlyEOF();
_handler.messageComplete(_contentPosition);
@ -1177,7 +1180,7 @@ public class HttpParser
default:
LOG.warn("Closing {}",this);
}
_state=State.CLOSED;
setState(State.CLOSED);
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
_contentPosition=0;
_responseStatus=0;
@ -1189,7 +1192,7 @@ public class HttpParser
public void reset()
{
// reset state
_state=State.START;
setState(State.START);
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
_contentPosition=0;
_responseStatus=0;
@ -1199,10 +1202,11 @@ public class HttpParser
}
/* ------------------------------------------------------------------------------- */
public void setState(State state)
private void setState(State state)
{
this._state=state;
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
if (_state==State.CLOSED && state==State.END)
new Throwable().printStackTrace();
_state=state;
}
/* ------------------------------------------------------------------------------- */

View File

@ -21,8 +21,6 @@ package org.eclipse.jetty.io;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
@ -30,6 +28,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
public abstract class AbstractEndPoint implements EndPoint
{
@ -38,8 +37,8 @@ public abstract class AbstractEndPoint implements EndPoint
private final InetSocketAddress _local;
private final InetSocketAddress _remote;
private final ScheduledExecutorService _scheduler;
private final AtomicReference<Future<?>> _timeout = new AtomicReference<>();
private final Scheduler _scheduler;
private final AtomicReference<Scheduler.Task> _timeout = new AtomicReference<>();
private final Runnable _idleTask = new Runnable()
{
@Override
@ -73,7 +72,7 @@ public abstract class AbstractEndPoint implements EndPoint
}
};
protected AbstractEndPoint(ScheduledExecutorService scheduler,InetSocketAddress local,InetSocketAddress remote)
protected AbstractEndPoint(Scheduler scheduler,InetSocketAddress local,InetSocketAddress remote)
{
_local=local;
_remote=remote;
@ -176,12 +175,12 @@ public abstract class AbstractEndPoint implements EndPoint
protected void scheduleIdleTimeout(long delay)
{
Future<?> newTimeout = null;
Scheduler.Task newTimeout = null;
if (isOpen() && delay > 0 && _scheduler!=null)
newTimeout = _scheduler.schedule(_idleTask, delay, TimeUnit.MILLISECONDS);
Future<?> oldTimeout = _timeout.getAndSet(newTimeout);
Scheduler.Task oldTimeout = _timeout.getAndSet(newTimeout);
if (oldTimeout != null)
oldTimeout.cancel(false);
oldTimeout.cancel();
}
protected long checkIdleTimeout()

View File

@ -96,20 +96,35 @@ public class ArrayByteBufferPool implements ByteBufferPool
{
if (size<=_min)
return null;
int b=size/_inc;
int b=(size-1)/_inc;
if (b>=_direct.length)
return null;
return direct?_direct[b]:_indirect[b];
Bucket bucket = direct?_direct[b]:_indirect[b];
return bucket;
}
private static class Bucket
public static class Bucket
{
final int _size;
final Queue<ByteBuffer> _queue= new ConcurrentLinkedQueue<>();
public final int _size;
public final Queue<ByteBuffer> _queue= new ConcurrentLinkedQueue<>();
Bucket(int size)
{
_size=size;
}
@Override
public String toString()
{
return String.format("Bucket@%x{%d,%d}",hashCode(),_size,_queue.size());
}
}
// Package local for testing
Bucket[] bucketsFor(boolean direct)
{
return direct ? _direct : _indirect;
}
}

Some files were not shown because too many files have changed in this diff Show More