[jira] Created: (SOAP-170) Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT state
"Jiping Yao (JIRA)" <[email protected]> Mon, 21 Aug 2006 10:57:15 -0700 (PDT)
| Newsgroups | gmane.text.xml.soap.devel |
|---|---|
| Message-ID | <16044560.1156183035949.JavaMail.jira@brutus> |
Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT state
------------------------------------------------------------------------------------------
Key: SOAP-170
URL: http://issues.apache.org/jira/browse/SOAP-170
Project: SOAP
Issue Type: Bug
Environment: Both Windows and UNIX
Reporter: Jiping Yao
Priority: Critical
I am not be able to send email to [email protected] so I opend it as bug regport.
Currently, I ran into the problem with every socket not closed as shown by numerous SOCKET_WAIT state after making SOAP call with apache.axis and those states are stayed there forever. Once we reach to the maximum number for SOCKET_WAIT state (operating system could not allocate any more connections as indicated by Too many open files), we could not make any SOAP call until we restart JVM.
Here is the original code where "currentMessage = currMsg;" could cuases the sokcet leaking (see JYao's comment)
public class SOAPPart extends javax.xml.soap.SOAPPart implements Part
{
.
.
.
private void setCurrentForm(Object currMsg, int form) {
if (log.isDebugEnabled()) {
String msgStr;
if (currMsg instanceof String) {
msgStr = (String)currMsg;
} else {
msgStr = currMsg.getClass().getName();
}
log.debug(Messages.getMessage("setMsgForm", formNames[form],
"" + msgStr));
}
// only change form if allowed
if (isFormOptimizationAllowed()) {
currentMessage = currMsg; // JYao's comment: socket is leaking here if currentMessage was an instance of SocketInputStream.
currentForm = form;
if (currentForm == FORM_SOAPENVELOPE) {
currentMessageAsEnvelope = (org.apache.axis.message.SOAPEnvelope) currMsg;
}
}
}
The following is what I changed for the same function within the block between of begin and end. After deployed recompiled code, all sockets allocated for apache.axix SOAP call are properly closed and the CLOSE_WAIT state associated with SOAP call is no longer seen by netstat -n in windows.
public class SOAPPart extends javax.xml.soap.SOAPPart implements Part
{
.
.
.
private void setCurrentForm(Object currMsg, int form) {
if (log.isDebugEnabled()) {
String msgStr;
if (currMsg instanceof String) {
msgStr = (String)currMsg;
} else {
msgStr = currMsg.getClass().getName();
}
log.debug(Messages.getMessage("setMsgForm", formNames[form],
"" + msgStr));
}
// only change form if allowed
if (isFormOptimizationAllowed()) {
// begin of JYao's change:
// currentMessage should be closed if it is an instance of SocketInputStream
// before to take any new instance of whatever SOAP message, otherwise the socket might be leaked
if (currentMessage instanceof SocketInputStream)
{
SocketInputStream socketInput = (SocketInputStream) currentMessage;
try
{
socketInput.close(); // the socket is properly closed
}
catch (IOException e)
{
// never got there
}
}
// end of JYao's change
currentMessage = currMsg; // JYao: safely take any other SOAP message
currentForm = form;
if (currentForm == FORM_SOAPENVELOPE) {
currentMessageAsEnvelope = (org.apache.axis.message.SOAPEnvelope) currMsg;
}
}
}
.
.
.
}
I am not sure if this is a bug or intended by authors. If it is not a bug, please give us advice how to get those sockets closed after each SOAP call.
Thanks,
Jiping Yao
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira