Skip to content
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

TypeData getNestedTypeData function should check for WildcardType #521

Closed
wants to merge 1 commit into from

Conversation

jbmolle
Copy link

@jbmolle jbmolle commented Aug 20, 2019

Hi,

I'm using the Mongo Java driver with Kotlin (through KMongo).
I've created a sealed class Account (it could also be an interface) and concrete classes InternalAccount and GoogleAccount which implement Account.

Then I've created a User model which has a list of accounts so List in Kotlin. The signature of this List in Kotlin is List so at runtime it gives the following signature in Java List<? extends Account>.
? extends Account is a WildcardType and getNestedTypeData don't recognize it so the list of accounts recovered from the database will be a list of Document. When I tried to get my user, I get an invalid cast exception with Document can't be cast to Account.
This pull request add the required conditional branch for WildcardType and solve the bug.

Best,
JB

@rozza
Copy link
Member

rozza commented Aug 21, 2019

Hi @jbmolle - thanks for the PR, looks good. I've added JAVA-3390 to track this.

Ross

@rozza rozza closed this Jan 7, 2020
@rozza
Copy link
Member

rozza commented Jan 7, 2020

This was fixed in 3.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants