Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Parsing of XML content with input fields > 512kb fails #551
I have test xml data with a binary resource which is > 512kb. When HAPI-FHIR tries to parse this an exception is thrown because the utilized XML woodstox library has 512kb as a default max size for a single attribute.
This issue has already been fixed some time ago but now this happens again because there is a check if the WstxInputFactory is used that does not work correctly any more:
XMLUtil.java line 1618:
thanks for looking into this! Woodstox is added as a maven dependency by HAPI-FHIR, woodstox-core-asl-4.4.1.jar so this should be correct i guess.
We are running HAPI_FHIR in an JBoss EAP 7 which seems to somehow wrap this factory class which is why the call to XMLInputFactory.newInstance(); returns this "__redirected.__XMLInputFactory". As far as i could find out this should affect all JBoss versions and not only EAP 7.
An easy solution to this would be to remove the instanceof check as adding the two properties to other implementations would not really have any downside.
Since the HAPI-FHIR build currently seems to be broken i am unable to fix/test this but if you wish i could look into this when the build is running again!
Unfortunately we can't set those properties blindly.. we used to do exactly that but this caused issues on Glassfish, where a non-woodstox StAX provider is used by default (SJSXP).. on that platform having unrecognized properties caused the parser to refuse to work.
I wonder if there is any way other than the
One option might be something like:
boolean isWoodstox = inputFactory.getProperty("org.codehaus.stax2.implVersion") != null;
You'd want to wrap that in a try-catch, but that could work.
Ps, build is passing again!
that is unfortunate. One would think that it would just ignore unknown properties ...
I now built HAPI-FHIR locally with the proposed fix (see attached diff) and it works as expected. I can also send a pull request if you like!