Mantis - Hessian
Viewing Issue Advanced Details
5093 major always 05-28-12 23:35 05-28-12 23:50
MicW  
 
normal  
new 4.0.7  
open  
none    
none  
0005093: Transfer of Large Binary Data not working within Objects
0003655 fixes the issue for 4.0.x for the case if a method returns an InputStream:

public InputStream getDownload(String filename);

But if the Stream is contained within a result Object, all Versions of Hessian (3.1.3, 3.1.5, 4.0.7) fails:

public Download getDownload(String filename);

public class Download {
   String filename;
   InputStream data;
}

The exception on the client side is like in 0003655 (Stream is closed).

Notes
(0005785)
MicW   
05-28-12 23:41   
java.io.IOException: stream is closed
    at sun.net.www.http.ChunkedInputStream.ensureOpen(ChunkedInputStream.java:151)
    at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:646)
    at java.io.FilterInputStream.read(FilterInputStream.java:116)
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2672)
    at com.caucho.hessian.io.Hessian2Input.readBuffer(Hessian2Input.java:2783)
    at com.caucho.hessian.io.Hessian2Input.read(Hessian2Input.java:2755)
    at com.caucho.hessian.io.Hessian2Input.parseByte(Hessian2Input.java:2638)
    at com.caucho.hessian.io.Hessian2Input.access$0(Hessian2Input.java:2594)
    at com.caucho.hessian.io.Hessian2Input$ReadInputStream.read(Hessian2Input.java:2904)
    at com.caucho.hessian.io.Hessian2Input$ReadInputStream.close(Hessian2Input.java:2927)
(0005786)
MicW   
05-28-12 23:50   
If i comment out is.close() and conn.close() in HessianProxy.invoke(), it works fine (but out course resources do not get closed).
So it's a bit tricky here how to close the stream and connection. In the fist case (0003655) the Method can only return one Stream. So the connection can simply be closed if this stream is closed. In the case of Objects containing streams, the situation is more complex because it's not easy to find out, when the stream can be closed. One way woulr be to keep track of all streams and if the last stream is closed, the connection can be closed as well.
Another problem is that the result Object's properties may not be available until the stream is fully read.