Hi,
 I have a mystery case that with missing bytes when read servlet inputstream.
I have hard time to pin point the cause and put an effective debugging code.
Any one has insight or suggestion on this would be very much appreciated.

I use apache web server and Jsev 1.1.2. The server receives lots email or
data uploading.
  The incoming requests are in XML format and feed to SAXParser upon arrival.
Everyday, I now constantly get about 50 or more exceptions thrown from SAX Parser
complaining either truncated data or no data at all(the input to parser is 
ServletInputStream
wrapped by a InputStreamReader and bufferedReader).
  In all of these missing bytes cases, the content length from HttpServletRequest
were always set properly and provide no clue. If I try to read inputstream
to a buffer before parse, when encounter missing bytes, the read() operation
would not return till 5 minutes later.(seems like a time out from the socket read).
Same delay would happen in parsing if I do not read out in forehand.

  5 minutes is a long time (it takes less than 100ms in normal case for read out),
I tried to use Inputstream.available(), it returned right away, but it returns
same thing as the ContentLength, even though I found missing or no bytes
when read them out.

I would really like to nail down where and why these data get lost.
And for now, I am struggling to find a dependable way to detect this
condition without such long delay.

Here is some relevant code:

  BufferedReader rd = new BufferedReader(
      new InputStreamReader(Decompressor.decompressData(
                             Decompressor.ZLIB_COMPRESSED, inputstream) ) );
  // debugging code, try to read input out
  CharArrayWriter writer = new CharArrayWriter();
  char bytes[] = new char[contentLen];
  while(true) {
    // this read will take 5 minutes if the missing bytes happening
    bytesRead = rd.read(bytes, 0, contentLen);
    if (bytesRead == -1)  {
      break;
    }
    writer.write(bytes, 0, bytesRead);
  }
  Reader reader = new CharArrayReader(writer.toCharArray());
  InputSource = new InputSource(reader);
  parser = new ValidatingParser ();
  parser.setErrorHandler (SAXErrorHandler.errorHandler);
  // the exceptions were thrown from here if I do not read them out
  parser.parse (in);


Thank you in advance for helping!

Dunping

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to