camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damien B (JIRA)" <>
Subject [jira] [Commented] (CAMEL-10504) Hiding an underlying exception if MongoDbBasicConverters fails to convert to DBObject
Date Wed, 17 May 2017 09:43:04 GMT


Damien B commented on CAMEL-10504:

Unfortunately it leads to another issue: when you want to use multiple inserts, the fromAnyObjectToDBObject
always fail and the logs are polluted with:
WARN  Conversion has fallen back to generic Object -> DBObject, but unable to convert type
org.apache.camel.impl.DefaultMessage. Returning null. java.lang.IllegalArgumentException:
Infinite recursion (StackOverflowError) (through reference chain: org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]->org.apache.camel.component.seda.SedaEndpoint["camelContext"]->org.apache.camel.impl.DefaultCamelContext["endpoints"]->java.util.ArrayList[0]

<to id="save_in_mongo"

Body content:
a java.util.List of objects that can be converted to DBObject.

            boolean singleInsert = true;
            Object insert = exchange1.getIn().getBody(DBObject.class);
            // body could not be converted to DBObject, check to see if it's of type List<DBObject>
            if (insert == null) {
                insert = exchange1.getIn().getBody(List.class);
                // if the body of type List was obtained, ensure that all items are of type
DBObject and cast the List to List<DBObject>
                if (insert != null) {
                    singleInsert = false;
                    insert = attemptConvertToList((List) insert, exchange1);
                } else {
                    throw new CamelMongoDbException("MongoDB operation = insert, Body is not
conversible to type DBObject nor List<DBObject>");
to check if this a singleInsert, the conversion is attempted on the body (the list, it fails)
then on the whole message (because of DefaultMessage::getBody). And then we see the cycles
between DefaultCamelContext and the Endpoints.

But of course the real problem is that we have a systematic stackoverflow when trying to use
multiple insert on the component, we see it only now because of this fix :-)

> Hiding an underlying exception if MongoDbBasicConverters fails to convert to DBObject
> -------------------------------------------------------------------------------------
>                 Key: CAMEL-10504
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mongodb
>    Affects Versions: 2.17.3, 2.18.0
>            Reporter: Evgenii Lomonosov
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 2.18.1, 2.19.0
> If conversion fails it could be hard to understand what is a problem because it returns
just a message "Conversion has fallen back to generic Object -> DBObject, but unable to
convert type {}. Returning null" that points to a class that was not converted.
> In case of, as example, if a list of objects that should be converted leads to a memory
error because of parent-child link are cycled for 2 objects, it would take a lot of efforts
to understand what is going on. And information about underlying exception, stackoverflow
in this case, could help to find the root cause much faster than now.

This message was sent by Atlassian JIRA

View raw message