473243 Delay resource close for async default content
This commit is contained in:
parent
4bd82d74df
commit
24c31527cb
|
@ -452,6 +452,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
// Find the resource and content
|
||||
Resource resource=null;
|
||||
HttpContent content=null;
|
||||
boolean close_content=true;
|
||||
try
|
||||
{
|
||||
// is gzip enabled?
|
||||
|
@ -529,7 +530,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
if (mt!=null)
|
||||
response.setContentType(mt);
|
||||
}
|
||||
sendData(request,response,included.booleanValue(),resource,content,reqRanges);
|
||||
close_content=sendData(request,response,included.booleanValue(),resource,content,reqRanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,10 +605,13 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (content!=null)
|
||||
content.release();
|
||||
else if (resource!=null)
|
||||
resource.close();
|
||||
if (close_content)
|
||||
{
|
||||
if (content!=null)
|
||||
content.release();
|
||||
else if (resource!=null)
|
||||
resource.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -887,11 +891,11 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void sendData(HttpServletRequest request,
|
||||
protected boolean sendData(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
boolean include,
|
||||
Resource resource,
|
||||
HttpContent content,
|
||||
final HttpContent content,
|
||||
Enumeration<String> reqRanges)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -955,6 +959,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
public void succeeded()
|
||||
{
|
||||
context.complete();
|
||||
content.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -965,6 +970,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
else
|
||||
LOG.warn(x);
|
||||
context.complete();
|
||||
content.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -973,12 +979,11 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
return String.format("DefaultServlet@%x$CB", DefaultServlet.this.hashCode());
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
// otherwise write content blocking
|
||||
else
|
||||
{
|
||||
((HttpOutput)out).sendContent(content);
|
||||
}
|
||||
((HttpOutput)out).sendContent(content);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -994,7 +999,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
response.setHeader(HttpHeader.CONTENT_RANGE.asString(),
|
||||
InclusiveByteRange.to416HeaderRangeString(content_length));
|
||||
resource.writeTo(out,0,content_length);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// if there is only a single valid range (must be satisfiable
|
||||
|
@ -1010,7 +1015,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
response.setHeader(HttpHeader.CONTENT_RANGE.asString(),
|
||||
singleSatisfiableRange.toHeaderRangeString(content_length));
|
||||
resource.writeTo(out,singleSatisfiableRange.getFirst(content_length),singleLength);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// multiple non-overlapping valid ranges cause a multipart
|
||||
|
@ -1090,7 +1095,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
in.close();
|
||||
multi.close();
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue