[ 
https://issues.apache.org/jira/browse/AXIS2-4723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12873254#action_12873254
 ] 

Andreas Veithen commented on AXIS2-4723:
----------------------------------------

TCPTransportSender needs some more attention, because neither the original code 
nor your new code is entirely correct.

The original code uses the correct lifecycle for the InputStream with the 
response: it is closed only in the cleanup method, and the invoke method 
doesn't consume the InputStream. That is important to enable deferred parsing. 
However, the InputStream (actually the corresponding Socket) is stored in an 
attribute of TCPTransportSender. That is of course wrong because 
TCPTransportSender may be invoked concurrently from multiple threads. Instead 
it should store the object in the MessageContext.

On the other hand, your implementation contains the following code to process 
the response:

            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    socket.getInputStream()));

            char[] cbuf = new char[1024];
            int len;
            StringBuffer buff = new StringBuffer();
            while ((len = reader.read(cbuf)) != -1) {
                buff.append(cbuf, 0, len);
            }

            ByteArrayInputStream bais = new 
ByteArrayInputStream(buff.toString().getBytes());

There are two issues with this code:
* There is no reason to go through a byte stream -> character stream -> byte 
stream transformation. Also, constructing an InputStreamReader or using 
String#getBytes without specifying a charset encoding is almost always a 
programming error (there are only very few cases where this would be correct). 
There will be a mismatch between the platform's default charset encoding and 
the encoding actually used by the message.
* It buffers the entire message, which (in part) defeats the purpose of 
deferred parsing.

> Make it Possible to Configure the TCP Transport at Service Level
> ----------------------------------------------------------------
>
>                 Key: AXIS2-4723
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4723
>             Project: Axis2
>          Issue Type: Improvement
>          Components: transports
>    Affects Versions: 1.5
>            Reporter: Hiranya Jayathilaka
>             Fix For: 1.6
>
>         Attachments: AXIS2-4723-update1.patch, AXIS2-4723-update2.patch, 
> AXIS2-4723-update3.patch, AXIS2-4723-update4.patch, AXIS2-4723.patch
>
>
> Currently the TCP transport can only be configured in the axis2.xml 
> (globally). It would be nice to be able to configure the transport at service 
> level. We can do this by using the Axis2TransportListenerEx API. (I will soon 
> attach a patch)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to