You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current design of AbstractUnmarshallerImpl has a serious negative performance impact when unmarshalling many XML files, which could easily be avoided.
Most JAXB documentation found anywhere including the JAXB Users Guide recommend creating a single JAXBContext and then new Unmarshallers for every unmarshalling tasks (the Users Guide recommends using object pooling for best performance, but many JAXB users will never have read that remark; also, this approach is more complex).
My issue with using JAXB in this "standard way" is that AbstractUnmarshallerImpl.getXMLReader() creates a new SAXParserFactory for every new Unmarshaller:
This is potentially quite an expensive operation, because the JAXP Lookup Mechanism uses the notoriously slow ServiceLoader mechanism. (this can be avoided by using system environment variables or jaxp.properties, but I highly doubt that this is a well-known fact)
It also seems unintuitive that a new factory with the same parameters is built over-and-over-again (e.g., we don't build a new car factory for every car we build, do we?)
My suggestion would be to make the well-documented default use-case of unmarshalling faster by creating a singleton SAXParserFactory in AbstractUnmarshallerImpl and re-using it in getXMLReader().
The text was updated successfully, but these errors were encountered:
The current design of
AbstractUnmarshallerImpl
has a serious negative performance impact when unmarshalling many XML files, which could easily be avoided.Most JAXB documentation found anywhere including the JAXB Users Guide recommend creating a single
JAXBContext
and then newUnmarshallers
for every unmarshalling tasks (the Users Guide recommends using object pooling for best performance, but many JAXB users will never have read that remark; also, this approach is more complex).My issue with using JAXB in this "standard way" is that
AbstractUnmarshallerImpl.getXMLReader()
creates a newSAXParserFactory
for every new Unmarshaller:jaxp.properties
, but I highly doubt that this is a well-known fact)My suggestion would be to make the well-documented default use-case of unmarshalling faster by creating a singleton
SAXParserFactory
inAbstractUnmarshallerImpl
and re-using it ingetXMLReader()
.The text was updated successfully, but these errors were encountered: