History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CAY-605
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Andrus Adamchik
Reporter: Andrus Adamchik
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cayenne

Hessian serialization mechanism converts Floats to Doubles

Created: 22/Jul/06 08:42 PM   Updated: 22/Jul/06 09:23 PM
Component/s: Cayenne Core Library
Affects Version/s: 1.2 [STABLE], 3.0
Fix Version/s: 1.2 [STABLE], 3.0


 Description  « Hide
If an entity has a field defined as java.lang.Float, then sending a client object to the server, and then retrieving it back results in this exception:

java.lang.IllegalArgumentException
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
        at java.lang.reflect.Field.set(Field.java:656)
        at org.objectstyle.cayenne.property.FieldAccessor.writePropertyDirectly(FieldAccessor.java:115)
        at org.objectstyle.cayenne.property.SimpleProperty.writePropertyDirectly(SimpleProperty.java:119)
        at org.objectstyle.cayenne.property.SimpleProperty.writeProperty(SimpleProperty.java:90)
        at org.objectstyle.cayenne.map.EntityDescriptor$SimplePersistentProperty.writeProperty(EntityDescriptor.java:341)
        at org.objectstyle.cayenne.util.ObjectDetachOperation$1.visitProperty(ObjectDetachOperation.java:195)
        at org.objectstyle.cayenne.property.SimpleProperty.visit(SimpleProperty.java:98)
        at org.objectstyle.cayenne.property.BaseClassDescriptor.visitProperties(BaseClassDescriptor.java:250)
        at org.objectstyle.cayenne.util.ObjectDetachOperation.detach(ObjectDetachOperation.java:134)
        at org.objectstyle.cayenne.access.ClientServerChannelQueryAction.toClientObjects(ClientServerChannelQueryAction.java:221)
        at org.objectstyle.cayenne.access.ClientServerChannelQueryAction.interceptObjectConversion(ClientServerChannelQueryAction.java:181)
        at org.objectstyle.cayenne.access.ClientServerChannelQueryAction.execute(ClientServerChannelQueryAction.java:106)
        at org.objectstyle.cayenne.access.ClientServerChannel.onQuery(ClientServerChannel.java:99)
        at org.objectstyle.cayenne.remote.service.DispatchHelper.dispatch(DispatchHelper.java:76)
        at org.objectstyle.cayenne.remote.service.BaseRemoteService.processMessage(BaseRemoteService.java:182)
 

As it turned out Hessian serializes Floats as Doubles... Will have to add a custom handler.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Andrus Adamchik - 22/Jul/06 09:23 PM
Something's fishy here. While Hessian does "expand" floats to doubles, this doesn't cause a problem in a regular fetch from the client. Only when it goes from client to server to client, as in the case reported by Marcel, which connects a peer CayenneContext to a shared remote session:

http://objectstyle.org/cayenne/lists/cayenne-devel/2006/07/0200.html
http://objectstyle.org/cayenne/lists/cayenne-devel/2006/07/0211.html

So looks like the problem is on deserializing GraphDiff on commit. GraphDiff is a generic structure, so hessian can't tell that double has to be narrowed back to Float, and the diff is applied to a CayenneDataObject, that is a map and doesn't care.