DWR

Object converter can't handle incoming collections

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Normal Normal
  • Resolution: Unresolved
  • Affects Version/s: 2.0.rc2
  • Fix Version/s: 4.0
  • Component/s: Converters
  • Description:
    Hide
    Sending an object containing f ex a List to the server results in the server code being invoked with a broken object structure as the converter can't decide what type the items are made of. Specifying item type with generics don't help, and neither does the signature section. Only solution is mapping to arrays on the server side (or use the bean converter instead).
    Show
    Sending an object containing f ex a List to the server results in the server code being invoked with a broken object structure as the converter can't decide what type the items are made of. Specifying item type with generics don't help, and neither does the signature section. Only solution is mapping to arrays on the server side (or use the bean converter instead).

Activity

Hide
Joe Walker added a comment - 13/Mar/07 7:30 PM

Mike commented:
I had a look at the source code and it seems like the org.directwebremoting.extend.Property hierarchy is making it harder to handle generic properties in the correct way. As you are only exposing the raw type from Property, it's hard to use it for looking up actual types. I see you have worked around this in BeanConverter.createTypeHintContext by taking the property's exposed setter method (later using your "getGenericParameterTypesMethod" on it) as this will also reveal the property's actual type, but this is not possible for ObjectConverter as there is no setter.

As this is a construct of your own, why not let both BeanConverter and ObjectConverter examine the Property's actual type? That will avoid the indirect way of having to examine the setter and will fix the issue with ObjectConverter...

Everything I say here is of course in the context of Java5, where you can examine actual generic types. In my opinion this is not so important to fix for earlier Java versions, especially as that would involve enhancing signatures.
The fix would either be to make it possible to create a TypeHintContext for a field, (not only for a method) from ObjectConverter.createTypeContext, or to simply let the actual generic type be sent into convertInbound of BasicObjectConverter's subclasses, and let them do the inspection themselves...

Show
Joe Walker added a comment - 13/Mar/07 7:30 PM Mike commented: I had a look at the source code and it seems like the org.directwebremoting.extend.Property hierarchy is making it harder to handle generic properties in the correct way. As you are only exposing the raw type from Property, it's hard to use it for looking up actual types. I see you have worked around this in BeanConverter.createTypeHintContext by taking the property's exposed setter method (later using your "getGenericParameterTypesMethod" on it) as this will also reveal the property's actual type, but this is not possible for ObjectConverter as there is no setter. As this is a construct of your own, why not let both BeanConverter and ObjectConverter examine the Property's actual type? That will avoid the indirect way of having to examine the setter and will fix the issue with ObjectConverter... Everything I say here is of course in the context of Java5, where you can examine actual generic types. In my opinion this is not so important to fix for earlier Java versions, especially as that would involve enhancing signatures. The fix would either be to make it possible to create a TypeHintContext for a field, (not only for a method) from ObjectConverter.createTypeContext, or to simply let the actual generic type be sent into convertInbound of BasicObjectConverter's subclasses, and let them do the inspection themselves...
Hide
Kenton added a comment - 16/Jan/08 11:13 PM

I also stumbled upon this bug. I found it quite difficult to understand what was occurring and almost started over thinking I was doing something wrong.

I'm using DWR with annotations. I looked over the ObjectConverter/BeanConverter source code and wondered if there should just be a ReflectionConverter that uses reflection (as opposed to Introspection on the BeanConverter) for these cases?

I'd be willing to code it out, but I want to make sure there isn't a reason I shouldn't do this, or is someone working on fixing this bug currently.

Let me know your thoughts...

Show
Kenton added a comment - 16/Jan/08 11:13 PM I also stumbled upon this bug. I found it quite difficult to understand what was occurring and almost started over thinking I was doing something wrong. I'm using DWR with annotations. I looked over the ObjectConverter/BeanConverter source code and wondered if there should just be a ReflectionConverter that uses reflection (as opposed to Introspection on the BeanConverter) for these cases? I'd be willing to code it out, but I want to make sure there isn't a reason I shouldn't do this, or is someone working on fixing this bug currently. Let me know your thoughts...
Hide
Philip Senger added a comment - 09/May/08 6:57 PM

Joe.

Is this issue related to methods with setters that have generic lists ( ie public void saveAll(Collection<Asset> assets) )?

We would really like to see this work without the work around discussed in
http://getahead.org/dwr/server/dwrxml/signatures

Thanks,
Phil

Show
Philip Senger added a comment - 09/May/08 6:57 PM Joe. Is this issue related to methods with setters that have generic lists ( ie public void saveAll(Collection<Asset> assets) )? We would really like to see this work without the work around discussed in http://getahead.org/dwr/server/dwrxml/signatures Thanks, Phil

People

Dates

  • Created:
    13/Mar/07 1:23 PM
    Updated:
    13/Apr/11 12:24 PM