fix bugs in CachingHttpContentFactory, ResourceService and FileMappedHttpContentFactory
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
0e1bae4059
commit
98c6675159
|
@ -217,7 +217,7 @@ public class CachingHttpContentFactory implements HttpContent.Factory
|
|||
|
||||
if (wasAdded.get())
|
||||
shrinkCache();
|
||||
return cachingHttpContent;
|
||||
return (cachingHttpContent instanceof NotFoundHttpContent) ? null : cachingHttpContent;
|
||||
}
|
||||
return httpContent;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FileMappedHttpContentFactory implements HttpContent.Factory
|
|||
public HttpContent getContent(String path) throws IOException
|
||||
{
|
||||
HttpContent content = _factory.getContent(path);
|
||||
if (content.getContentLengthValue() > 16 * 1024)
|
||||
if (content != null && content.getContentLengthValue() > 16 * 1024)
|
||||
return new FileMappedContent(content);
|
||||
return content;
|
||||
}
|
||||
|
|
|
@ -868,10 +868,10 @@ public class ResourceService
|
|||
@Override
|
||||
protected Action process() throws Throwable
|
||||
{
|
||||
// TODO: use BufferUtil
|
||||
if (!source.isOpen())
|
||||
return Action.SUCCEEDED;
|
||||
byteBuffer.clear();
|
||||
|
||||
BufferUtil.clearToFill(byteBuffer.getBuffer());
|
||||
int read = source.read(byteBuffer.getBuffer());
|
||||
if (read == -1)
|
||||
{
|
||||
|
@ -879,7 +879,7 @@ public class ResourceService
|
|||
sink.write(true, BufferUtil.EMPTY_BUFFER, this);
|
||||
return Action.SCHEDULED;
|
||||
}
|
||||
byteBuffer.getBuffer().flip();
|
||||
BufferUtil.flipToFlush(byteBuffer.getBuffer(), 0);
|
||||
sink.write(false, byteBuffer.getBuffer(), this);
|
||||
return Action.SCHEDULED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue