Re: Hessian PHP implementation

From: Christian Campo <christian.campo@xxx.com>
Date: Thu Jan 13 2005 - 09:17:54 PST

I trying to grab the more important ones. :-)

The ThrowableSerializer has a problem that it will only serialize
private fields of exception if they exist in the Throwable class. That
is if you extend Throwable with your own Exception and add private
fields, they don't get through the wire. The problem is the
constructor of ThrowableSerializer:
------------------------------------------------------
public ThrowableSerializer(Class cl)
  {
// super(Throwable.class); that is the old call to super();
    super(cl);
  }
--------------------------------------------------------
- The Java Calendar class has a LARGER (really large) number of
private fields of which most of are of no interest to you. If you want
to pass a Calendar object in a parameter, you get a few 100 bytes in
the Hessian protocol for a simple Date. So I wrote my own Serializer
for Calender for which I then had to change the SerializerFactory to
add it. It found that quite helpful. It simple converts the Calendar
into a Date and the Deserilizer converts the Date back to a Calendar.
10 lines of code but it codenses your parameter by the factor of 10.

- Deserializing Arrays sometimes seemed to create an Object[] rather
then a typed array like YourType[].(which then results into an
Exception) A change in the ArrayDeserializer helped a lot:
-------------------------------------------------------------------------------------------------------
  /** CHANGED to return the correct Type of the Array **/
  public Class getType()
  {
          if (_componentType==null || _componentType.getName()==null) {
                  return Object[].class;
          }
          try {
          return Class.forName("[L"+_componentType.getName()+";");
          } catch (ClassNotFoundException e) {
                  return Object[].class;
          }
// return Object[].class;
  }
-------------------------------------------------------------------------------------------------------
- bug fix that Scott posted which is not in 3.0.8 and which was
promised for 3.0.10: class is HessianOutput
-------------------------------------------------------------------------------------------------------
  /**
   * Writes a reference.
   *
   * <code><pre>
   * R b32 b24 b16 b8
   * </pre></code>
   * CHANGED from << to >>
   * @param value the integer value to write.
   */
  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);
  }
--------------------------------------------------------------------------------------------------------
- add this to HessianRuntimeException to get the whole chain of causes with
  their stacktrace
-------------------------------------------------------------------------------------------------------
  /**
   * @see java.lang.Throwable#getCause()
   */
  public Throwable getCause() {
        return rootCause;
  }
--------------------------------------------------------------------------------------------------------
so far about the fixes we did:

ideas:
- better error handling (HessianRuntimeException or
HessianProtocolException is most times not good enough)
- did you ever try to create a webservice that had two methods with
the same name but different signature ??? My users tried that and all
you get is "Unexpected code: M" :-) I know its forbidden, but a
clearer message would
help
- GZIP requests and responses, hopefully by using HTTP Headers so that
the client triggers whether he wants GZIPping or not
- optionally logging error message on the server when they occurr
- and there is always more :-)

how is that for a start ?

kind regards
christian campo

On Thu, 13 Jan 2005 18:19:06 +0200, Radu-Adrian Popescu
<radu.popescu@xxx.com> wrote:
> Christian Campo wrote:
>
> > I remember reading a bug fix from Scott from several month ago, where
> > he promised a certain bug fix (that I need back then) for a version
> > 3.0.10, which hasn't surfaced yet.
> >
> > Since I needed it I fixed the bug myself, and added several small but
> > nice things to the Java implementation. (Gzip of Hessian streams, a
> > bug fix for Arrays where a webservice call would return an Object[]
> > instead of the array of the correct type, and some improvements in
> > HessianRuntimeException where it stores the cause of the exception in
> > the rootCause and not the cause with the result that the cause of a
> > HessianRuntimeException is not shown in the stacktrace)
> >
>
> I'd be interested to get a diff against the original 3.0.8 source for these
> bugs. Can you provide that ? I'm a more recent subscriber to this list and was
> not aware of such problems. TIA.
> I've implemented Gzip too and was tempted to hack on the exception thing, but
> eventually I chose not to touch the exception part.
>
> > I have more ideas on what could be improved. Anybody willing to say
> > something about the future timeline ?
> >
>
> Care to post a list ?
>
> > thanks very much
> >
> > christian campo
> >
>
> Cheers,
> --
> Radu-Adrian Popescu
> CSA, DBA, Developer
> Aldrapay MD
> Aldratech Ltd.
> +40213212243
>
>
>

-- 
christian campo (gmail.com)
Received on Thu 13 Jan 2005 09:17:54 -0800

This archive was generated by hypermail 2.1.8 : Thu Sep 28 2006 - 20:16:40 PDT