Uploaded image for project: 'Mule'
  1. Mule
  2. MULE-5955

AbstractAnnotatedTransformerArgumentResolver returns a jaxbContext the first time only even when it should not

    Details

    • Type: Patch submission
    • Status: Closed
    • Priority: Critical
    • Resolution: Won't Fix or Usage Issue
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Modules: (other)
    • Labels:
      None
    • User impact:
      Low
    • Configuration:
      Hide

      <mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
      xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
      xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
      xsi:schemaLocation="
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
      http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.1/mule-vm.xsd
      http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd
      http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/1.0/mule-mongo.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      ">

      <mulexml:jaxb-context name="jaxbContext" packageNames="org.mule.entity"/>
      <mulexml:jaxb-object-to-xml-transformer name="jaxbTransformer" jaxbContext-ref="jaxbContext" />

      <mongo:config name="mongo" database="test" host="localhost" port="27017"/>

      <flow name="testJaxbAndMongo">
      <vm:inbound-endpoint address="vm://test" exchange-pattern="request-response"/>
      <logger level="ERROR" message="#[payload]"/>
      <mongo:update-objects collection="test-collection" config-ref="mongo" multi="false" upsert="true"
      query="

      { "id" : #[json:id] }

      " element="#[payload]" />
      </flow>
      </mule>

      Show
      <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.1/mule-vm.xsd http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/1.0/mule-mongo.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "> <mulexml:jaxb-context name="jaxbContext" packageNames="org.mule.entity"/> <mulexml:jaxb-object-to-xml-transformer name="jaxbTransformer" jaxbContext-ref="jaxbContext" /> <mongo:config name="mongo" database="test" host="localhost" port="27017"/> <flow name="testJaxbAndMongo"> <vm:inbound-endpoint address="vm://test" exchange-pattern="request-response"/> <logger level="ERROR" message="# [payload] "/> <mongo:update-objects collection="test-collection" config-ref="mongo" multi="false" upsert="true" query=" { "id" : #[json:id] } " element="# [payload] " /> </flow> </mule>
    • Similar Issues:

      Description

      Mongo db connector has a property upsert (boolean) on the update-objects element. The auto generated code will try to find a transformer to convert from string to boolean to get the proper value from the XML configuration. This works fine until you introduce a Jaxb context to your Mule configuration. Once you add a jaxb context, a JAXBContextResolver will start appearing in the list of transformer resolvers. When Mule tries to find a transformer to convert String to Boolean, the first time only the jaxb resolver will return a jaxb context to be used by the transformer for the conversion. Obviously this will throw an exception when the transformer is eventually invoked. Second time round however, everything works fine because the JAXBContextResolver returns null!!

      The issue is found in the AbstractAnnotatedTransformerArgumentResolver. In the resolve, if the arguments are not correctly annotated, the classes are added correctly to the nonMatchingClasses set so that next time round we return null immediately without having to scan. However, the first time round, the context is still returned even though the arguments are not properly annotated!! Second time round, everything works fine because the argument classes would be in the nonMatchingClasses and a null is immediately returned.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alan.cassar Alan Cassar
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: