Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-07-21 23:11:40 -0400
committerGreg Wilkins2015-07-21 23:44:46 -0400
commit24c31527cb009026a0a8c843909379c8bcb54979 (patch)
treef0bb235929827c9d072759bcc74348f51f0cfca9 /jetty-servlet
parent4bd82d74df2bc4083ac608db4f2b023cd1291859 (diff)
downloadorg.eclipse.jetty.project-24c31527cb009026a0a8c843909379c8bcb54979.tar.gz
org.eclipse.jetty.project-24c31527cb009026a0a8c843909379c8bcb54979.tar.xz
org.eclipse.jetty.project-24c31527cb009026a0a8c843909379c8bcb54979.zip
473243 Delay resource close for async default content
Diffstat (limited to 'jetty-servlet')
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
index c98804f304..97c6173945 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
@@ -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;
}
/* ------------------------------------------------------------ */

Back to the top