Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1402

org.jboss.resteasy.plugins.providers.jaxb.XmlJAXBContextFinder should not cache JAXBContext coming from user ContextResolver<JAXBContext>

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.1.0.Beta1, 3.0.20.Final
    • 3.0.13.Final, 3.0.14.Final, 3.0.15.Final, 3.0.16.Final, 3.0.17.Final
    • jaxrs

    Description

      Because of caching in XmlJAXBContextFinder (see XmlJAXBContextFinder.findCachedContext()) user can't define two ContextResolver<JAXBContext> for a same generic container type on two separate webTarget instances (see XmlJAXBContextFinderTest.java).

      The goal of ContextResolver is to let user provides context information to a provider. So if registered by user it must be called and taken into account by the provider. Plus, there is nothing nothing preventing the user from registering two ContextResolver<JAXBContext> on totally separate webTarget instances (one is not inheriting from the other so https://issues.jboss.org/browse/RESTEASY-1284 does not apply).

      Maybe it would have been better, to always call user custom ContextResolver<JAXBContext> first and not cache JAXBContext instance coming from them. Only JAXBContext created by XmlJAXBContextFinder.createContext should be cached.

      Doing that it's up to the user implementing its own ContextResolver<JAXBContext> to also implement similar kind of cache mechanism as it is done in XmlJAXBContextFinder or any JAXBContext lazy loading pattern just like in the test example.

      Attachments

        Activity

          Public project attachment banner

            context keys: [headless, issue, helper, isAsynchronousRequest, project, action, user]
            current Project key: RESTEASY

            People

              rhn-support-asoldano Alessio Soldano
              nicones Nicolas NESMON (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: