ffang commented on PR #3781:
URL: https://github.com/apache/cxf/pull/3781#issuecomment-7167569827
Thanks @coheigea, the fix is right: the null-namespace context is stored
under "", so the exact lookup has to read "" too. The new test fails on main
and passes with the PR.
One side effect, though: the cache key is the class set plus the default
namespace, and it ignores props. Before this change, an exact lookup with no
default namespace always missed, so every caller got a context built with its
own properties. Now the first caller's context is returned for later calls with
the same classes, whatever properties they pass. This affects:
- getCachedContextAndSchemas(String pkg, Map props, ClassLoader), which
always passes a null default namespace;
- JAXBDataBinding.createJAXBContextAndSchemas(), which passes the endpoint's
contextProperties with exact=true. The default namespace is forced to null when
an ObjectFactory declares elements in the empty namespace, the case mentioned
in the description.
To check, I called getCachedContextAndSchemas(pkg, null, loader) and then
getCachedContextAndSchemas(pkg,
Map.of("org.glassfish.jaxb.defaultNamespaceRemap", "urn:probe"), loader) for
the same package. On main they return different contexts; with this PR they
return the same one, so the remap is ignored. Two endpoints with the same
classes but different JAXB properties (an annotation reader, subclass
replacements, a namespace remap) would now share a context.
This already happens when the default namespace is non-null, so it isn't
new, but the null case used to behave correctly. Could we either:
1. include props in the key of the per-class map (for example the default
namespace together with the props), or
2. skip the cache when props is non-empty, as is already done for typeRefs?
Option 1 keeps the caching and fixes the non-null case too. A test with two
different property maps for the same package would cover it either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]