From: SourceForge.net <no...@so...> - 2006-02-22 10:10:56
|
Bugs item #1431936, was opened at 2006-02-15 03:50 Message generated for change (Settings changed) made by gregwilkins You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107322&aid=1431936&group_id=7322 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Servlets Group: None Status: Open >Resolution: Fixed Priority: 5 Submitted By: ct_dev (ct_dev) Assigned to: Greg Wilkins (gregwilkins) Summary: ServletOutputStream(PrintWriter)'s problem Initial Comment: I create two new test servlet on my public host,the test urls are: http://159.226.125.78:9000/jjmap/servlet/Test?count=49 http://159.226.125.78:9000/jjmap/servlet/Test1?count=49 the count parameter can change which represent the data item's count. Test.java's thread(OK, no problem): ... response.setContentType("text/xml;charset=utf-8");ByteArrayOutputStream data = new ByteArrayOutputStream(); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(data, response.getCharacterEncoding())); ... output some data ... out.flush(); response.setIntHeader("Content-Length", data.size()); data.writeTo(response.getOutputStream()); out.close(); Test1.java's thread(has problem): ... response.setContentType("text/xml;charset=utf-8"); PrintWriter out = response.getWriter(); ... the code here same as Test.java ... out.flush(); out.close(); ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-22 08:14 Message: Logged In: YES user_id=44062 The problem was that if the client blocked the server while sending data, then the last chunk marker "0<CR><LF><CR><LF>" was left in the buffer and then got rechunked to "5<CR><LF>"0<CR><LF><CR><LF>"<CR><LF>" so the client never saw the end of the chunking! Generator was not marking the buffer as chunked when it added the end of chunking chunk. fixed in SVN now. ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-21 19:01 Message: Logged In: YES user_id=44062 OK - I've reproduced it now! I have a test harness that varies the length of the write. investigating now.... thanks for your persistance. ---------------------------------------------------------------------- Comment By: ct_dev (ct_dev) Date: 2006-02-21 13:42 Message: Logged In: YES user_id=1450750 I found the problem relate NIO! when config jetty.xml as <!-- Use this connector if NIO is not available. --> <Item> <New class="org.mortbay.jetty.bio.SocketConnector"> <Set name="port">80</Set> </New> </Item> Both Test.java and Test1.java work perfectly every time. when config jetty.xml as <Item> <New class="org.mortbay.jetty.nio.SelectChannelConnector"> <Set name="port">80</Set> <Set name="maxIdleTime">50000</Set> <Set name="Acceptors">10</Set> </New> </Item> Test.java works perfectly every time,but Test1.java can work sometime,once Test1.java fails when change the 'count' parameter,all flow tests fail. ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-21 09:23 Message: Logged In: YES user_id=44062 There are also differences in the way the data is converted from characters to bytes. The test that works uses a standard Writer to do the conversion. The test that does not work uses the Writer from the response to do the conversion. The response writer has some moderately complex code to do the conversion to bytes, trying to avoid creating extra arrays etc. So I suspect the problem could be in that code. If the problem was in the chunking code, then I would expect to be able to reproduce it with any test data. I guess the other option is that it is not the characters in the data, but the length of the data? I will try a test with random length data and see if I can reproduce the problem that way. Other than that, could you turn debug on in your server and capture the output when test1 fails? thanks ---------------------------------------------------------------------- Comment By: ct_dev (ct_dev) Date: 2006-02-21 07:10 Message: Logged In: YES user_id=1450750 why http://159.226.125.78:9000/jjmap/servlet/Test?count=9 and http://159.226.125.78:9000/jjmap/servlet/Test1?count=9 works perfectly? I have test Test1.jsp that very like Test1.java,the Transfer-Encoding is chunked also,but Test1.jsp works perfectly. ---------------------------------------------------------------------- Comment By: ct_dev (ct_dev) Date: 2006-02-21 06:58 Message: Logged In: YES user_id=1450750 "So it must be a problem with international characters."... but Test.java and Test1.java retrive the same data from mysql,the diff is the Transfer-Encoding,Test.java use explicite length but Test1.java use chunked. but why http://159.226.125.78:9000/jjmap/servlet/Test?count=9 and http://159.226.125.78:9000/jjmap/servlet/Test?count=9 works perfectly? ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-20 14:48 Message: Logged In: YES user_id=44062 I still cannot replicate the problem? I have attached the test class that I am using. It uses the xml file downloaded from http://159.226.125.78:9000/jjmap/servlet/Test?count=49 as input to get the data. It works without flaw on my system. Can you try this class on your system and tell me if you ge t the problem? files are attached. ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-20 11:29 Message: Logged In: YES user_id=44062 Test1 works perfectly for me with my own test data. So it must be a problem with international characters. I will try and download your test data from your test site and then retest with that. ---------------------------------------------------------------------- Comment By: ct_dev (ct_dev) Date: 2006-02-20 03:19 Message: Logged In: YES user_id=1450750 I Upload the Test1.java and Test.java ---------------------------------------------------------------------- Comment By: Greg Wilkins (gregwilkins) Date: 2006-02-19 11:17 Message: Logged In: YES user_id=44062 Can you please send me the exact source code for test1? I can see that http://159.226.125.78:9000/jjmap/servlet/Test1?count=49 fails, but the code you have given me does not reproduce the problem. ---------------------------------------------------------------------- Comment By: ct_dev (ct_dev) Date: 2006-02-15 04:04 Message: Logged In: YES user_id=1450750 when set the count paramter to a small value blow 9,both Test.java and Test1.java has no problem, when set a big value > 9,Test1.java has problem ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107322&aid=1431936&group_id=7322 |