You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
I'm using GWTP with gwtp-dispatch-rest version 1.6, which uses gwt-jackson version 0.14.1.
Gwt-jackson is used for the DTO serialization.
Basically, I had the following DTO:
public class MyDto {
List<NestedDto> nestedDtos = new ArrayList<NestedDto>();
public void setNestedDtos(List<NestedDto> nestedDtos) {
this.nestedDtos = nestedDtos;
}
public List<NestedDto> getNestedDtos() {
return this.nestedDtos;
}
public List<NestedDto> getNestedDtos(String someFilter) {
List<NestedDto> filteredDtos = new ArrayList<NestedDto>();
// add nestedDtos that fit the filter...
return filteredDtos
}
}
Gwt-jackson did not automatically generate deserializers for List<NestedDto> nestedDtos, because the PropertyParser seemingly got confused when parsing the methods of MyDto.
In the current git master (0.14.3-SNAPSHOT), but probably since some time, PropertyParser#parseMethods(...) adds all methods as a setter to PropertyAccessorsBuilder, that have on parameter and fit the property name 'nestedDtos'. Since the getter with the filter also fits the constraint of having one parameter, it is also added as as setter, although it is a getter.
If that getter is also the first 'setter' to be added for that builder, it will then be the setter for that Property (even if there are multiple other correct setters).
Later in the build process, in the PropertyProcessor#processProperty(...), you check whether the setter is auto detected. This fails, because the setter does not start with "set", see PropertyProcessor#isSetterAutoDetected(...) line 331. Because of this, no setter is added to the builder and ultimately the serialization/deserialization fails. (My actual DTO was quite a bit more complex and my specific exception was due to some other failure even later, when a NestedDto was referenced, although it was never deserialized because of that getter-setter issue.)
In the end, for me the solution was just to slightly rename the method into 'getNestedDtosFiltered(...)' so it no longer was recognized as a setter.
I also tried to mark the correct setter with @JsonSetter or @JsonAnySetter and later the wrong 'setter' with @JsonIgnore (although the semantic of @JsonIgnore is a bit different afaik). Both did not seem to help. Please let me know, if I used these annotations in the wrong way (or if there would have been a combination that should have worked).
My guess is, that you should probably check the type of the method parameter, if the method does not start with 'set' in the PropertyParser... or maybe have a look at how @JsonSetter is used.
Thanks
Albrecht
The text was updated successfully, but these errors were encountered:
Hey,
I'm using GWTP with gwtp-dispatch-rest version 1.6, which uses gwt-jackson version 0.14.1.
Gwt-jackson is used for the DTO serialization.
Basically, I had the following DTO:
Gwt-jackson did not automatically generate deserializers for
List<NestedDto> nestedDtos
, because the PropertyParser seemingly got confused when parsing the methods of MyDto.In the current git master (0.14.3-SNAPSHOT), but probably since some time, PropertyParser#parseMethods(...) adds all methods as a setter to PropertyAccessorsBuilder, that have on parameter and fit the property name 'nestedDtos'. Since the getter with the filter also fits the constraint of having one parameter, it is also added as as setter, although it is a getter.
If that getter is also the first 'setter' to be added for that builder, it will then be the setter for that Property (even if there are multiple other correct setters).
Later in the build process, in the PropertyProcessor#processProperty(...), you check whether the setter is auto detected. This fails, because the setter does not start with "set", see PropertyProcessor#isSetterAutoDetected(...) line 331. Because of this, no setter is added to the builder and ultimately the serialization/deserialization fails. (My actual DTO was quite a bit more complex and my specific exception was due to some other failure even later, when a NestedDto was referenced, although it was never deserialized because of that getter-setter issue.)
In the end, for me the solution was just to slightly rename the method into 'getNestedDtosFiltered(...)' so it no longer was recognized as a setter.
I also tried to mark the correct setter with
@JsonSetter
or@JsonAnySetter
and later the wrong 'setter' with@JsonIgnore
(although the semantic of@JsonIgnore
is a bit different afaik). Both did not seem to help. Please let me know, if I used these annotations in the wrong way (or if there would have been a combination that should have worked).My guess is, that you should probably check the type of the method parameter, if the method does not start with 'set' in the PropertyParser... or maybe have a look at how @JsonSetter is used.
Thanks
Albrecht
The text was updated successfully, but these errors were encountered: