title: getting Java Bad File Descriptor Close Bug while reading multipart/form-data http body
body: <p>My web service hosted on Play! framework. I have few image files uploaded from a non-play! framework based client using the standard HTTP client request with content-type of multipart/form-data. </p>
  
  <p>On the web service side, I tried using Play! ApacheMultipartParser to parse the Http.request.body, but failed with the Java IO Bad File Descriptor exception. </p>
  
  <p>The problem seems come from Java MultipartStream, by looking at the following callstack</p>
  
  <pre><code>    at java.io.FileInputStream.readBytes(Native Method)
      at java.io.FileInputStream.read(FileInputStream.java:208)
      at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:976)
      at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:886)
      at java.io.InputStream.read(InputStream.java:85)
  </code></pre>
  
  <p>I also tried directly reading the http.request.body into a big buffer for experiment, got the same exception. What could be wrong? </p>
  
  <p>The http data sent out from client side is something like the following. On web service side, I could using IO.write to save it to a file w/o any problem. </p>
  
  <pre><code>Content-Type: multipart/form-data; boundary=--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
  
  --3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
  Content-Disposition: form-data; name="foo1.jpg"; filename="foo1.jpg"
  Content-Length: 5578
  Content-Type: image/jpeg
  
  &lt;image data 1 omitted&gt;
  --3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
  Content-Disposition: form-data; name="foo2.jpg"; filename="foo2.jpg"
  Content-Length: 327
  Content-Type: image/jpeg
  
  &lt;image data 2 omitted&gt;
  --3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--
  </code></pre>