Merge remote-tracking branch 'origin/master' into jetty-http2

Conflicts:
	jetty-distribution/pom.xml
This commit is contained in:
Greg Wilkins 2014-08-14 08:38:25 +10:00
commit 98b654ba20
9 changed files with 86 additions and 63 deletions

View File

@ -8,3 +8,5 @@ org.eclipse.jetty.SOURCE=false
#org.eclipse.jetty.io.LEVEL=DEBUG #org.eclipse.jetty.io.LEVEL=DEBUG
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG #org.eclipse.jetty.io.ssl.LEVEL=DEBUG
#org.eclipse.jetty.spdy.server.LEVEL=DEBUG #org.eclipse.jetty.spdy.server.LEVEL=DEBUG
#org.eclipse.jetty.server.LEVEL=DEBUG
#org.eclipse.jetty.servlets.LEVEL=DEBUG

View File

@ -302,7 +302,7 @@
<configuration> <configuration>
<includeGroupIds>org.eclipse.jetty</includeGroupIds> <includeGroupIds>org.eclipse.jetty</includeGroupIds>
<excludeGroupIds>org.eclipse.jetty.orbit,org.eclipse.jetty.http2,org.eclipse.jetty.spdy,org.eclipse.jetty.websocket,org.eclipse.jetty.fcgi,org.eclipse.jetty.toolchain,org.apache.taglibs</excludeGroupIds> <excludeGroupIds>org.eclipse.jetty.orbit,org.eclipse.jetty.http2,org.eclipse.jetty.spdy,org.eclipse.jetty.websocket,org.eclipse.jetty.fcgi,org.eclipse.jetty.toolchain,org.apache.taglibs</excludeGroupIds>
<excludeArtifactIds>jetty-all,jetty-jsp,apache-jsp,jetty-start,jetty-monitor,jetty-spring</excludeArtifactIds> <excludeArtifactIds>jetty-all,jetty-jsp,apache-jsp,apache-jstl,jetty-start,jetty-monitor,jetty-spring</excludeArtifactIds>
<includeTypes>jar</includeTypes> <includeTypes>jar</includeTypes>
<outputDirectory>${assembly-directory}/lib</outputDirectory> <outputDirectory>${assembly-directory}/lib</outputDirectory>
</configuration> </configuration>

View File

@ -168,5 +168,11 @@ public interface HttpContent
{ {
_resource.close(); _resource.close();
} }
@Override
public String toString()
{
return String.format("%s@%x{r=%s}",this.getClass().getSimpleName(),hashCode(),_resource);
}
} }
} }

View File

@ -176,71 +176,63 @@ public abstract class NoSqlSessionManager extends AbstractSessionManager impleme
@Override @Override
protected boolean removeSession(String idInCluster) protected boolean removeSession(String idInCluster)
{ {
synchronized (this) NoSqlSession session = _sessions.remove(idInCluster);
try
{ {
NoSqlSession session = _sessions.remove(idInCluster); if (session != null)
try
{ {
if (session != null) return remove(session);
{
return remove(session);
}
} }
catch (Exception e)
{
__log.warn("Problem deleting session {}", idInCluster,e);
}
return session != null;
} }
catch (Exception e)
{
__log.warn("Problem deleting session {}", idInCluster,e);
}
return session != null;
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected void expire( String idInCluster ) protected void expire( String idInCluster )
{ {
synchronized (this) //get the session from memory
{ NoSqlSession session = _sessions.get(idInCluster);
//get the session from memory
NoSqlSession session = _sessions.get(idInCluster);
try try
{
if (session == null)
{ {
if (session == null) //we need to expire the session with its listeners, so load it
{ session = loadSession(idInCluster);
//we need to expire the session with its listeners, so load it
session = loadSession(idInCluster);
}
if (session != null)
session.timeout();
}
catch (Exception e)
{
__log.warn("Problem expiring session {}", idInCluster,e);
} }
if (session != null)
session.timeout();
}
catch (Exception e)
{
__log.warn("Problem expiring session {}", idInCluster,e);
} }
} }
public void invalidateSession (String idInCluster) public void invalidateSession (String idInCluster)
{ {
synchronized (this) NoSqlSession session = _sessions.get(idInCluster);
try
{ {
NoSqlSession session = _sessions.get(idInCluster); __log.debug("invalidating session {}", idInCluster);
try if (session != null)
{ {
__log.debug("invalidating session {}", idInCluster); session.invalidate();
if (session != null)
{
session.invalidate();
}
}
catch (Exception e)
{
__log.warn("Problem invalidating session {}", idInCluster,e);
} }
} }
catch (Exception e)
{
__log.warn("Problem invalidating session {}", idInCluster,e);
}
} }

View File

@ -643,6 +643,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
if (buffer!=null) if (buffer!=null)
{ {
if (LOG.isDebugEnabled())
LOG.debug("sendContent({}=={},{},direct={})",httpContent,BufferUtil.toDetailString(buffer),callback,_channel.useDirectBuffers());
sendContent(buffer,callback); sendContent(buffer,callback);
return; return;
} }
@ -650,6 +653,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
ReadableByteChannel rbc=httpContent.getReadableByteChannel(); ReadableByteChannel rbc=httpContent.getReadableByteChannel();
if (rbc!=null) 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 // Close of the rbc is done by the async sendContent
sendContent(rbc,callback); sendContent(rbc,callback);
return; return;
@ -658,6 +663,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
InputStream in = httpContent.getInputStream(); InputStream in = httpContent.getInputStream();
if ( in!=null ) if ( in!=null )
{ {
if (LOG.isDebugEnabled())
LOG.debug("sendContent({}=={},{},direct={})",httpContent,in,callback,_channel.useDirectBuffers());
sendContent(in,callback); sendContent(in,callback);
return; return;
} }

View File

@ -504,7 +504,7 @@ public class ResourceCache
@Override @Override
public String toString() public String toString()
{ {
return String.format("%s %s %d %s %s",_resource,_resource.exists(),_resource.lastModified(),_contentType,_lastModifiedBytes); return String.format("CachedContent@%x{r=%s,e=%b,lm=%d,ct=%s}",hashCode(),_resource,_resource.exists(),BufferUtil.toString(_lastModifiedBytes),_contentType);
} }
} }
} }

View File

@ -494,7 +494,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
} }
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("uri="+request.getRequestURI()+" resource="+resource+(content!=null?" content":"")); LOG.debug(String.format("uri=%s, resource=%s, content=%s",request.getRequestURI(),resource,content));
// Handle resource // Handle resource
if (resource==null || !resource.exists()) if (resource==null || !resource.exists())
@ -863,7 +863,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
throws IOException throws IOException
{ {
final long content_length = (content==null)?resource.length():content.getContentLength(); final long content_length = (content==null)?resource.length():content.getContentLength();
// Get the output stream (or writer) // Get the output stream (or writer)
OutputStream out =null; OutputStream out =null;
boolean written; boolean written;
@ -881,6 +881,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
out = new WriterOutputStream(response.getWriter()); out = new WriterOutputStream(response.getWriter());
written=true; // there may be data in writer buffer, so assume written written=true; // there may be data in writer buffer, so assume written
} }
if (LOG.isDebugEnabled())
LOG.debug(String.format("sendData content=%s out=%s async=%b",content,out,request.isAsyncSupported()));
if ( reqRanges == null || !reqRanges.hasMoreElements() || content_length<0) if ( reqRanges == null || !reqRanges.hasMoreElements() || content_length<0)
{ {
@ -935,6 +938,12 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
LOG.warn(x); LOG.warn(x);
context.complete(); context.complete();
} }
@Override
public String toString()
{
return String.format("DefaultServlet@%x$CB", DefaultServlet.this.hashCode());
}
}); });
} }
// otherwise write content blocking // otherwise write content blocking

View File

@ -304,6 +304,8 @@ public class GzipHttpOutput extends HttpOutput
if (!_complete) if (!_complete)
return Action.SUCCEEDED; return Action.SUCCEEDED;
_deflater.finish();
} }
BufferUtil.compact(_buffer); BufferUtil.compact(_buffer);
@ -324,22 +326,22 @@ public class GzipHttpOutput extends HttpOutput
{ {
private final ByteBuffer _input; private final ByteBuffer _input;
private final ByteBuffer _content; private final ByteBuffer _content;
private final boolean _complete; private final boolean _last;
public GzipBufferCB(ByteBuffer content, boolean complete, Callback callback) public GzipBufferCB(ByteBuffer content, boolean complete, Callback callback)
{ {
super(callback); super(callback);
_input=getHttpChannel().getByteBufferPool().acquire(Math.min(_factory.getBufferSize(),content.remaining()),false); _input=getHttpChannel().getByteBufferPool().acquire(Math.min(_factory.getBufferSize(),content.remaining()),false);
_content=content; _content=content;
_complete=complete; _last=complete;
} }
@Override @Override
protected Action process() throws Exception protected Action process() throws Exception
{ {
if (_deflater.needsInput()) if (_deflater.needsInput())
{ {
if (BufferUtil.isEmpty(_content)) if (BufferUtil.isEmpty(_content))
{ {
if (_deflater.finished()) if (_deflater.finished())
{ {
_factory.recycle(_deflater); _factory.recycle(_deflater);
@ -349,40 +351,45 @@ public class GzipHttpOutput extends HttpOutput
return Action.SUCCEEDED; return Action.SUCCEEDED;
} }
if (!_complete) if (!_last)
{
return Action.SUCCEEDED; return Action.SUCCEEDED;
}
_deflater.finish();
} }
else else
{ {
BufferUtil.clearToFill(_input); BufferUtil.clearToFill(_input);
BufferUtil.put(_content,_input); int took=BufferUtil.put(_content,_input);
BufferUtil.flipToFlush(_input,0); BufferUtil.flipToFlush(_input,0);
if (took==0)
throw new IllegalStateException();
byte[] array=_input.array(); byte[] array=_input.array();
int off=_input.arrayOffset()+_input.position(); int off=_input.arrayOffset()+_input.position();
int len=_input.remaining(); int len=_input.remaining();
_crc.update(array,off,len); _crc.update(array,off,len);
_deflater.setInput(array,off,len); _deflater.setInput(array,off,len);
if (_complete && BufferUtil.isEmpty(_content)) if (_last && BufferUtil.isEmpty(_content))
_deflater.finish(); _deflater.finish();
} }
} }
BufferUtil.compact(_buffer); BufferUtil.compact(_buffer);
int off=_buffer.arrayOffset()+_buffer.limit(); int off=_buffer.arrayOffset()+_buffer.limit();
int len=_buffer.capacity()-_buffer.limit() - (_complete?8:0); int len=_buffer.capacity()-_buffer.limit() - (_last?8:0);
int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH); int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH);
_buffer.limit(_buffer.limit()+produced); _buffer.limit(_buffer.limit()+produced);
boolean complete=_deflater.finished(); boolean finished=_deflater.finished();
if (complete) if (finished)
addTrailer(); addTrailer();
superWrite(_buffer,complete,this); superWrite(_buffer,finished,this);
return Action.SCHEDULED; return Action.SCHEDULED;
} }
} }
} }

View File

@ -542,7 +542,7 @@
<dependency> <dependency>
<groupId>org.mortbay.jasper</groupId> <groupId>org.mortbay.jasper</groupId>
<artifactId>apache-jsp</artifactId> <artifactId>apache-jsp</artifactId>
<version>8.0.9.M0</version> <version>8.0.9.M1</version>
</dependency> </dependency>
<dependency> <dependency>