users@jaxb.java.net

Fwd: Reused UnmarshallingContext omits errors when errorsCounter is exceeded

From: Sebastian Bathke <sebastian.bathke_at_gmail.com>
Date: Fri, 27 Nov 2015 08:59:00 +0100

Hi,

we just stumbled over this as an adjacent system upgraded its schema
containing new elements.
At first we got the expected "javax.xml.bind.UnmarshalException: unexpected
element" errors but suddenly they vanished and everythin worked as if the
schema violation wouldn't be present, but it still was.

Debugging this case lead to the UnmarshallingContext#shouldErrorBeReported
method and the errorCounter. I wonder whether this is a feature or a bug,
why would jaxb ever stop to report errors for new messages only because
previous ones already had errors? We are using cxf jaxws clients that
reuses the UnmarshallingContext instance.

I prepared a simple project to demonstrate the issue:
https://github.com/megglos/cxfIncomaptibleServerSample . Please see
the SpringClient
class it sends requests to a server that responds with a different element
than expected, after the 10th requests it stops throwing errors because of
the errorCounter feature and the catch isn't reached anymore.

Jaxb 2.2.11

Would greatly appreciate any clarification to this, is it a bug or a
feature if the latter what's the reason? Or should cxf just simply not
reuse the unmarshallingConext for multiple request/response transactions?

Thanks

Sebastian