Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003655 [Hessian] minor always 08-28-09 08:51 07-29-19 13:54
Reporter ferg View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.63 Product Version 4.0.1
  Product Build
Summary 0003655: Hessian InputStream result is closed
Description (rep by Mattias Jiderhamn)
After upgrading from Resin/Hessian 3.1 to 4.0.1 we have a problem
returning InputStream from Hessian calls.
I get this exception while trying to read the stream on the client:

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:2446)
  at com.caucho.hessian.io.Hessian2Input.readBuffer(Hessian2Input.java:2689)
  at com.caucho.hessian.io.Hessian2Input.read(Hessian2Input.java:2635)
  at com.caucho.hessian.io.Hessian2Input$ReadInputStream.read(Hessian2Input.java:2785)
...


I created a small testcase which just sends the output of a
Hessian2Output to a Hessian2Input and in that case, InputStream works fine.

The proxy is created using Springs HessianProxyFactoryBean.

Any tips on how to debug this???

  
Steps To Reproduce
Both client and server is using Hessian included in Resin 4.0.1. Here is a detailed test case (without Spring):

Service interface:
public interface HessianTest {
  InputStream testString(String input);
}

Service implementation:
public class HessianTestImpl implements HessianTest {
  public InputStream testString(String s) {
    return new ByteArrayInputStream(s.getBytes());
  }
}

Service configuration; web.xml:
  <servlet-mapping url-pattern="/hessian/test" servlet-class="com.caucho.hessian.server.HessianServlet">
    <init-param>
      <api-class>foo.HessianTest</api-class>
      <service-class>foo.HessianTestImpl</service-class>
    </init-param>
  </servlet-mapping>

Test case:
    HessianProxyFactory hessianProxyFactory = new HessianProxyFactory();
    // Workaround for http://bugs.caucho.com/view.php?id=3634 [^]
    hessianProxyFactory.setSerializerFactory(new SerializerFactory() {
      protected Deserializer loadDeserializer(Class cl) throws HessianProtocolException {
        if (InputStream.class.isAssignableFrom(cl))
          return new InputStreamDeserializer();
        else
          return super.loadDeserializer(cl);
      }
    });
    HessianTest hessianTest = (HessianTest) hessianProxyFactory.create(HessianTest.class, "http://localhost/hessian/test"); [^]
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < 512; i++) {
      final int digit = (i % 10) + 1;
      sb.append(digit);
      System.out.println("No of chars: " + sb.length());
      InputStream is = hessianTest.testString(sb.toString());
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      assertEquals(sb.toString(), br.readLine());
    }

Output:
No of chars: 1
No of chars: 2
No of chars: 3
No of chars: 4
No of chars: 5
No of chars: 6
No of chars: 7
No of chars: 8
No of chars: 9
No of chars: 11
No of chars: 12
No of chars: 13
No of chars: 14
No of chars: 15
No of chars: 16
No of chars: 17
No of chars: 18
No of chars: 19

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:2391)
    at com.caucho.hessian.io.Hessian2Input.readBuffer(Hessian2Input.java:2689)
    at com.caucho.hessian.io.Hessian2Input.read(Hessian2Input.java:2661)
    at com.caucho.hessian.io.Hessian2Input.read(Hessian2Input.java:2603)
    at com.caucho.hessian.io.Hessian2Input$ReadInputStream.read(Hessian2Input.java:2785)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at se.exder.HessianInputStreamTest.testHessianTest(HessianInputStreamTest.java:80)
...

 </Mattias>

Additional Information
Attached Files  Hessian_3000655.patch [^] (571 bytes) 08-28-09 09:46

- Relationships

- Notes
(0004196)
Peter Dettman
08-28-09 09:49

I was able to reproduce Mattias' issue, and tracked the problem down to HessianProxy (see attached patch). The call to http.disconnect in the finally block of the invoke method was causing the reply to be truncated. I have copied the handling for Hessian 1 'InputStream' replies and it appears to fix the problem.
 
(0004545)
stefanthurnherr
04-26-10 03:46

Hi Hessian team

Any chance that this gets fixed in the next official minor/major release? I just hit the same bug using resin-hessian 4.0.3 on the server side, and hessian-4.0.3 on the client side.
 
(0004686)
fabdouglas
07-29-10 14:17

This bug exists in 4.0.7, and the attached patch works very well for this version.

Any change to get it in 4.0.8?
 
(0004869)
selikoff
12-09-10 12:39

Is there a reason this bug has not been resolved? The solution works perfectly. Without the fix transferring/downloading files is broken in Hessian 4.
 
(0005058)
Holy
02-15-11 07:26

Hello, is there a chance to get this patch to next release? And is there a time plan for this release? Thx
 
(0005379)
selikoff
07-18-11 12:12
edited on: 07-18-11 12:13

Could someone please include this fix in the next release? I'd update the SVN myself, but I'm not familiar with the repository.

You just need to update src/com/caucho/hessian/client/HessianProxy.java and add:

    if (value instanceof InputStream) {
            value = new ResultInputStream(conn, is, in, (InputStream) value);
            is = null;
            conn = null;
    }

After line:

Object value = in.readReply(method.getReturnType());

I've verified it as solving the issue.

 
(0006909)
tiendat
07-27-19 05:37

Dear experts,

I have been able to reproduced this issue in Hessian v4.0.38.

Just wonder if this issue was fixed in the newest version?

Best
Tien Dat
 
(0006910)
ferg
07-29-19 13:54

hessian/34c1
 

- Issue History
Date Modified Username Field Change
08-28-09 08:51 ferg New Issue
08-28-09 09:46 Peter Dettman File Added: Hessian_3000655.patch
08-28-09 09:49 Peter Dettman Note Added: 0004196
08-28-09 09:50 Peter Dettman Issue Monitored: Peter Dettman
08-30-09 11:25 mate Issue Monitored: mate
04-26-10 03:46 stefanthurnherr Note Added: 0004545
04-26-10 03:49 stefanthurnherr Issue Monitored: stefanthurnherr
07-29-10 14:17 fabdouglas Note Added: 0004686
07-29-10 14:17 fabdouglas Issue Monitored: fabdouglas
12-09-10 12:39 selikoff Note Added: 0004869
02-15-11 07:23 Holy Issue Monitored: Holy
02-15-11 07:26 Holy Note Added: 0005058
06-14-11 05:38 jsbret Issue Monitored: jsbret
07-18-11 12:12 selikoff Note Added: 0005379
07-18-11 12:13 selikoff Note Edited: 0005379
07-18-11 12:13 selikoff Issue Monitored: selikoff
07-27-19 05:37 tiendat Note Added: 0006909
07-29-19 13:54 ferg Note Added: 0006910
07-29-19 13:54 ferg Assigned To  => ferg
07-29-19 13:54 ferg Status new => closed
07-29-19 13:54 ferg Resolution open => fixed
07-29-19 13:54 ferg Fixed in Version  => 4.0.63
07-29-19 13:54 ferg Steps to Reproduce Updated


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
60 total queries executed.
40 unique queries executed.
Powered by Mantis Bugtracker