Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2
-
None
-
None
-
Windows XP Professional
Tomcat 4.1.31
Java 1.4.2_04-b05
Description
While requesting a webservice through HTTP POST, I'm getting an ArrayIndexOutOfBoundsException. Debugging into this, it turned out that there is a bug in org.apache.axis.transport.HTTPSender.writeToSocket(...).
On line 331 there is a code sequence like this:
if (posting) {
String contentType;
if (mimeHeaders.getHeader(HTTPConstants.HEADER_CONTENT_TYPE) != null)
header2.append(HTTPConstants.HEADER_CONTENT_TYPE)
.append(": ")
.append(contentType)
.append("\r\n");
}
In my case mimeHeaders.getHeader(...) returned an empty String array, which causes the bug on the next line. Changeing that code to test for empty sting arrays as well fixes the problem:
if (posting) {
String contentType;
Object[] test = mimeHeaders.getHeader(HTTPConstants.HEADER_CONTENT_TYPE);
if (test != null && test.length > 0) { contentType = mimeHeaders.getHeader(HTTPConstants.HEADER_CONTENT_TYPE)[0]; }
else
{ contentType = reqMessage.getContentType(msgContext.getSOAPConstants()); } header2.append(HTTPConstants.HEADER_CONTENT_TYPE)
.append(": ")
.append(contentType)
.append("\r\n");
}