-
Couldn't load subscription status.
- Fork 30
Sprout for fix #248 #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sprout for fix #248 #249
Conversation
…` objects during deserialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for starting to put all this together. I provided some initial feedback.
src/main/java/com/microsoft/graph/serializer/CollectionResponseSerializer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/graph/serializer/DerivedClassIdentifier.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/graph/serializer/FallbackTypeAdapterFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/graph/serializer/FallbackTypeAdapterFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/graph/serializer/FallbackTypeAdapterFactory.java
Outdated
Show resolved
Hide resolved
|
@PrimosK Also wanted to let you know about the following error from the api linting: |
…tory requires synthetic accessor".
|
Hi @baywet, is there any progress with this pull request? Is there any further help needed? One of the concerns I see (and could be improved) is the fact that adding new ... without adding it to: ... might result in unexpected behavior as With that in mind I wonder whether changing public <T> TypeAdapter<T> create(@Nonnull final Gson gson, @Nonnull final TypeToken<T> type) {
Objects.requireNonNull(type, "parameter type cannot be null");
final Class<T> rawType = (Class<T>) type.getRawType();
if (rawType.isEnum()) {
return new EnumTypeAdapter<>(rawType, logger);
} else if (rawType == Void.class) {
return (TypeAdapter<T>) voidAdapter;
} else if (IJsonBackedObject.class.isAssignableFrom(type.getRawType())) {
final TypeAdapter<IJsonBackedObject> delegatedAdapter = (TypeAdapter<IJsonBackedObject>) gson.getDelegateAdapter(this, type);
// Avoid overriding custom IJsonBackedObject type adapters defined in GsonFactory
if (!(delegatedAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) {
return null;
}
return (TypeAdapter<T>) new ODataTypeParametrizedIJsonBackedObjectAdapter(gson, delegatedAdapter, (TypeToken<IJsonBackedObject>) type, logger);
}
else {
return null;
}
} |
|
@PrimosK sorry, I thought you were still working on it since it's still in a draft state. When you are ready, please switch it from draft to open via the "ready to review" button. The main missing thing I can see at this point are additional unit tests to test for the case we're fixing in this PR. Having something dynamic that relies on the factory would probably be better indeed if the performance impact is not too high. This would prevent us from potentially shooting ourselves in the foot in the future. Thanks for considering it. |
…e adapters defined in GsonFactory are not overridden.
|
BTW - I guess I can't do nothing about static analysis with SonarCloud failing:
|
src/test/java/com/microsoft/graph/serializer/FallbackTypeAdapterFactoryTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for making changes, a few minor comments left.
And no, sonarqube requires access to a secret, and PRs from forks don't have access to secrets for security reasons, we'll run it once it gets merged.
src/main/java/com/microsoft/graph/serializer/FallbackTypeAdapterFactory.java
Outdated
Show resolved
Hide resolved
- DefaultSerializer - CollectionResponseDeserializer ... as this is now taken care by ODataTypeParametrizedJsonBackedTypeAdapter. Tests covering this change: - com.microsoft.graph.serializer.DefaultSerializerTest.testDeserializationOfObjectWithODataTypeProperty - com.microsoft.graph.serializer.ODataTypeParametrizedIJsonBackedTypedAdapterTest.testDeserializationOfNestedODataTypeAnnotatedObjects
|
I think that should be it. In the future some improvements might be made also WRT: .. being called from various places. I think these could be simply called inside: ... but I am considering this a separate issue to keep the scope of this PR manageable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! thanks for making all the adjustments! @ramsessanchez can you have a look as well please? and run a few tests locally?
|
It's nice to see that this fix was merged to 2.0.8. Are there any plans/approximations of when new 2.0.8 release will be out? |
|
We'll probably take advantage of this release to test the migration of our release pipelines (last item in the milestone). The work has started on that, so let's have a tentative date by the end of next week. (ramses here just joined the team, and we need to account for the ramp-up) |
Sprout for fix which downcasts parametrized nested
IJsonBackedObject…objects during deserialization.fixes #248 (sprout)
As deserialization of (nested)
IJsonBackedObjectis dependent based on the payload (Odata.type) the only way of doing it was to extendFallbackTypeAdapterFactoryaccordingly. So ifOdata.typeis present a new sub type adapter is created/used otherwise default Gson adapter is used.As I am ATM short on time to look into this further I would highly appreciate if someone with the better overview of the related codebase would take it over from there.
All in all - I can confirm that this change fixes the issue observed in #248.