Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004100 [Hessian] minor always 07-01-10 08:08 07-01-10 08:08
Reporter ferg View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version
Summary 0004100: replace StringBuffer with StringBuilder for Android
Description (rep by dilbert.elbonia)

I ran into this issue while using Hessian on the Android platform. Android version 1.6 is severely affected and the problem is less serious on 2.1. In short the Hessian class uses (and reuses) a private member StringBuffer _sbuf. Here is a snippet from said class:

case 0x30: case 0x31: case 0x32: case 0x33:
      _isLastChunk = true;
      _chunkLength = (tag - 0x30) * 256 + read();


      while ((ch = parseChar()) >= 0)
        _sbuf.append((char) ch);

      return _sbuf.toString();

This piece of code reads a char from the input and appends it to the _sbuf. When finished it returns the string to the caller via the toString() call. Due to an error in the Andriod implementation (for details check: [^] it is possible that the call will return a string that occupies far more memory space than needed which is very bad on mobile devices. Also it seems that earlier Java implementations suffered from a similar problem: [^]
Since this is not strictly a Hessian bug I am reluctant to post a bug report but maybe a replacement of StringBuffer with a local StringBuilder should be considered. I made the replacement in my version and it solved the problem.
Additional Information
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
07-01-10 08:08 ferg New Issue

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