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

Is Jongo compatible with Jackson 2.8.x #321

Closed
hlassiege opened this issue Dec 10, 2017 · 6 comments
Closed

Is Jongo compatible with Jackson 2.8.x #321

hlassiege opened this issue Dec 10, 2017 · 6 comments
Milestone

Comments

@hlassiege
Copy link

Hi,

I just upgraded to Spring Boot 1.5.x and I'm using Jongo 1.3.
Spring Boot 1.5.x upgraded its Jackson dependency to 2.8.x. Officially Jongo is compatible with Jackson 2.7.x.

At first, I thought everything was ok but our tests detected a weird behaviour. I'm not sure it's related to Jongo (I'm pretty sure it's not) but I'm curious if you encountered such a thing.

We have a piece of code who works previously like that :

 private FutureAccount find(ObjectId objectId) {
            return futureAccounts.findOne(objectId).as(FutureAccount.class);
    }

futureAccounts is collection. This collections has only objects of type FutureAccount which inherit from SimpleAccount
(FutureAccount extends SimpleAccount)

This code works fine before the upgrade.

Now, the deserialization complains :

java.lang.IllegalArgumentException: Class com.malt.commons.account.SimpleAccount not subtype of [simple type, class com.malt.model.account.FutureAccount]

	at com.fasterxml.jackson.databind.type.TypeFactory.constructSpecializedType(TypeFactory.java:359)
	at com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder.buildTypeDeserializer(StdTypeResolverBuilder.java:128)
	at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findTypeDeserializer(BasicDeserializerFactory.java:1372)
	at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:482)
	at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:1902)
	at com.fasterxml.jackson.databind.ObjectReader.<init>(ObjectReader.java:185)
	at com.fasterxml.jackson.databind.ObjectMapper._newReader(ObjectMapper.java:652)
	at com.fasterxml.jackson.databind.ObjectMapper.reader(ObjectMapper.java:3472)
	at org.jongo.marshall.jackson.configuration.DefaultReaderCallback.getReader(DefaultReaderCallback.java:24)

It would work if we change the previous code like this :

 private FutureAccount find(ObjectId objectId) {
            return (FutureAccount)futureAccounts.findOne(objectId).as(SimpleAccount.class);
    }

Of course it's more problematic for every methods returning an iterable.

Did you encounter this behaviour before ?

@bguerout
Copy link
Owner

Hello,

AFAIK Jongo is compatible with Jackson 2.8.
You can find more informations here : #319

What is the exact version you are using ?

@hlassiege
Copy link
Author

hlassiege commented Dec 11, 2017 via email

@bguerout
Copy link
Owner

Can you test with the work in progress version of Jongo (1.4) ?

<dependencies>
  <dependency>
    <groupId>org.jongo</groupId>
    <artifactId>jongo</artifactId>
    <version>jongo-1.4-early-20171013-1609</version>
  </dependency>
</dependencies>
...
<repositories>
    <repository>
       <id>cloudbees-jongo-early-release</id>
        <url>http://repository-jongo.forge.cloudbees.com/release</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

@hlassiege
Copy link
Author

ok I'll test it next week I think. Thanks

@hlassiege
Copy link
Author

Currently I resolved this behaviour modification by changing this line kind of statement :

accounts.findOne(objectId).as(FutureAccount.class)

by

(FutureAccount)accounts.findOne(objectId).as(SimpleAccount.class)

Ths change is centralized in the repository so it's ok for me.

@bguerout bguerout added this to the 1.4.0 milestone Feb 18, 2018
@bguerout
Copy link
Owner

Hello 1.3.1 and 1.4.0 have been released.

1.3.1: Jackson fixAcces(true) and Jackson update to 2.7.9
1.4.0: Jackson and bson4jackson updated to 2.9.x and enhancement of Jongo classes extensibility

You can find more informations here: https://github.com/bguerout/jongo/releases

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

No branches or pull requests

2 participants