Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000069 [Resin] minor always 03-01-05 00:00 05-11-05 00:00
Reporter user102 View Status public  
Assigned To
Priority normal Resolution fixed  
Status closed   Product Version
Summary 0000069: hessian references break when there are more than 256 refs in one call
Description RSN-60
When you create a Large hessian Object that has more than 256 references in it,
using HessianOutput.writeObject() can produce unpredictable results.
The reason for this is the implementation of HessianOutput.writeRef() as following:

public void writeRef(int value)
    throws IOException
  {
    os.write('R');
    os.write(value << 24);
    os.write(value << 16);
    os.write(value << 8);
    os.write(value);
  }

the above code does bitshifting to the left and write out the value. This will work as long as
the reference value is smaller than 256 because the shifting will not affect the higher bytes, as
they are zero anyway. but anything bigger than 256 will give strange results, resulting in difficult to debug error messages, because the references will not point to the correct objects.
This can cause ClassCastExceptions and other Exceptions.

The solution i found to this problem is the following code:

 /*corrected this function so that reference bigger than 256 can work!! i
    * in hessian, the bits were being shifted to the left instead of right
    * @see com.caucho.hessian.io.AbstractHessianOutput#writeRef(int)
    */
    public void writeRef(int value)
      throws IOException
    {
      os.write('R');
      os.write((value >> 24) & 0xFF);
      os.write((value >> 16) & 0xFF);
      os.write((value >> 8) & 0xFF);
      os.write((value) & 0xFF);
    }

this code correctly shifts the bits to the right and everything works fine.

Additional Information linux
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
03-01-05 00:00 user102 New Issue
11-30-05 00:00 administrator Fixed in Version  => 3.0.13


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