Mantis - Hessian
Viewing Issue Advanced Details
2998 crash always 10-09-08 06:59 09-05-23 01:37
gritstone  
 
normal  
new 3.2.0  
open  
none    
none  
0002998: Hessian deserialization crashes on on multi java.util.TimeZone responses
A hessian client crashes deserializing the response if the response contains two java.util.TimeZone objects representing different timezones. This fails on Java SE 6u2 and Java SE 6u7.

The client crashes with the following exception:
com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianFieldException: sun.util.calendar.ZoneInfo.transitions: [J cannot be assigned from null
    at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:232)
    at $Proxy0.echoTimeZoneList(Unknown Source)
    at ZonedDateTimeTest.main(ZonedDateTimeTest.java:49)
Caused by: com.caucho.hessian.io.HessianFieldException: sun.util.calendar.ZoneInfo.transitions: [J cannot be assigned from null
    at com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:677)
    at com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:400)
    at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233)
    at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157)
    at com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:378)
    at com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2051)
    at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1977)
    at com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:78)
    at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1700)
    at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:220)
    ... 2 more
Caused by: java.lang.UnsupportedOperationException: com.caucho.hessian.io.BasicDeserializer@6754d6
    at com.caucho.hessian.io.BasicDeserializer.readLengthList(BasicDeserializer.java:598)
    at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1714)
    at com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:396)
    ... 10 more
com.caucho.hessian.io.HessianFieldException: sun.util.calendar.ZoneInfo.transitions: [J cannot be assigned from null
Sample server:

public interface ZonedDateTimeServer {

    public List<TimeZone> echoTimeZoneList(List<TimeZone> times);
}


Sample implementation:
public class ZonedDateTimeServerImpl implements ZonedDateTimeServer {
    @Override
    public List<TimeZone> echoTimeZoneList(List<TimeZone> times) {
        List<TimeZone> list = new ArrayList<TimeZone>();
        for (TimeZone time : times) {
            System.out.println("Adding TimeZone: " + time.toString());
            list.add(time);
        }
        return list;
    }
}

Sample client:
public class ZonedDateTimeTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            String url = "http://localhost:8080/date-time-server/hello"; [^]
    
            HessianProxyFactory factory = new HessianProxyFactory();
            factory.setDebug(true);
            ZonedDateTimeServer dtServer = (ZonedDateTimeServer) factory.create(ZonedDateTimeServer.class, url);
    
            /* Works */
            TimeZone la = TimeZone.getTimeZone("America/Los_Angeles");
            List<TimeZone> responseList = dtServer.echoTimeZoneList(Collections.singletonList(la));
            System.out.println("LA Response: " + responseList);
  
            /* Works */
            TimeZone london = TimeZone.getTimeZone("Europe/London");
            responseList = dtServer.echoTimeZoneList(Collections.singletonList(london));
            System.out.println("London Response: " + responseList);

            /* Fails */
            List<TimeZone> tzList = new ArrayList<TimeZone>();
            tzList.add(la);
            tzList.add(london);
            responseList = dtServer.echoTimeZoneList(tzList);
            System.out.println("LA + London: " + responseList);
        } catch (final Exception e ) {
            e.printStackTrace();
            System.err.println(e.getLocalizedMessage());
        }
    }
}

Notes
(0003528)
valysivec27   
10-01-08 17:52   
I'm having the same issue :(