users@glassfish.java.net

Re: What causes GRIZZLY to flood the Glassfish-Log with messages

From: <forums_at_java.net>
Date: Mon, 8 Oct 2012 04:36:16 -0500 (CDT)

Hey Alexey, good news from the bad world !!! :-) The patch which was provided
by Harshad Vilekar on the thread [1] works fine for our problem with GF. Last
Friday we had again the situation, that the GF detects an idle thread and
tries to interrupt it. … Now with success !!! :-) Obviously the patched GF
is now able to interrupt the faulty thread. Now we see our implemented
error-messages in the GF-log which gives us more informations about the main
cause of the problem. In our case we tried to read from the InputStream of
the request, which obviously crashes when the length of the submitted
XML-File is 0. I think that our problem was reading from an InputStream which
has a length of 0 and was caused by the following lines of code: … try {
xmlString = getValue(request.getInputStream()); } catch (Exception e) { ...
System.out.println("Error in Methode : processRequest");
System.out.println("Error Message : " + e.getMessage()); } … … private
String getValue(InputStream is)throws IOException { BufferedInputStream bis =
new BufferedInputStream(is); ByteArrayOutputStream buf = new
ByteArrayOutputStream(); int result = bis.read(); while(result != -1) { byte
b = (byte)result; buf.write(b); result = bis.read(); } return buf.toString();
} Apart from that the patch of Harshad Vilekar will make a good job, we
modified our source code with the following lines: try {
if(request.getInputStream().available() > 0){ xmlString =
getValue(request.getInputStream()); }else{ xmlString = ""; } } catch
(Exception e) { ... System.out.println("Error in Methode : processRequest");
System.out.println("Error Message : " + e.getMessage()); } Now we first check
the InpuStream of the request, if there is something in to read. If not, we
can react on that situation and will not have to rely on the GF
error-handling. ;-) I keep observing GF-logs for the rest of the week, but i
think we made it. Many many thanks for your support right now. If we reach
the end of this week/month without any hanging threads, i call you my
personal hero !!! ;-) Cheers, Gerhard [1]
http://java.net/jira/browse/GLASSFISH-16217 [1]

[1] http://java.net/jira/browse/GLASSFISH-16217

--
[Message sent by forum member 'GrhrdBlmln']
View Post: http://forums.java.net/node/889790