On 1/7/07, Leo Simons <[EMAIL PROTECTED]> wrote:
On Dec 23, 2006, at 4:06 AM, [EMAIL PROTECTED] wrote:
> * src/test/java/org/apache/speedyfeed/test/BasicTest.java
>   (BasicServlet.doGet): Remember to close the stream.
(...)
> @@ -57,8 +59,12 @@
>        byte buffer[] = new byte[1024];
>        int len;
>
> -      while ((len = in.read(buffer)) != -1) {
> -        out.write(buffer, 0, len);
> +      try {
> +        while ((len = in.read(buffer)) != -1) {
> +          out.write(buffer, 0, len);
> +        }
> +      } finally {
> +        out.close();
>        }
>      }
>    }

Just FYI, in servlets, IIRC (not done servlets in a while, perhaps
someone can confirm my rusty memory) it is usually better to not flush
() or close() any container-provided output stream. This allows the
servlet container to do various things better (like http pipes, post
request filters, ...); I do know it matters with WebLogic.

The servlet container is required to close the stream appropriately
by the servlet spec.

See, the reason I put in the explicit close was that I wasn't ever
getting it called without that, and thus the filter (which is dumb and
buffers all the data up so it can process it once at the end, due to
lack of a way to slowly feed data to Abdera) didn't work.  Is this
indicative of a problem in Jetty?  Or is it just that sticking work
inside the close method is a Bad Idea (tm) in the first place?

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to