Skip to content

Fix NPE and DocumentBuilder race in HubClientFault/XmlUtils - #92

Open
ebrockainq wants to merge 1 commit into
developfrom
IGDD-2679-unexpected-exception-in-izgw-hub
Open

Fix NPE and DocumentBuilder race in HubClientFault/XmlUtils#92
ebrockainq wants to merge 1 commit into
developfrom
IGDD-2679-unexpected-exception-in-izgw-hub

Conversation

@ebrockainq

Copy link
Copy Markdown
Contributor

documentElementIsError() called getFirstChild().getNodeName() without checking getFirstChild() for null, causing an NPE when building fault messages for destination SOAP faults.

XmlUtils shared a single static DocumentBuilder across all threads; DocumentBuilder isn't thread-safe, so concurrent parseDocument() calls could corrupt parser state and return a document with no children, triggering the NPE above. Switched to a ThreadLocal.

Added tests for both issues and verified
against the pre-fix code to confirm they reproduce the original bugs.

documentElementIsError() called getFirstChild().getNodeName() without
checking getFirstChild() for null, causing an NPE when building fault messages for destination SOAP faults.

XmlUtils shared a single static DocumentBuilder across all threads; DocumentBuilder isn't thread-safe, so concurrent parseDocument() calls could corrupt parser state and return a document with no children, triggering the NPE above. Switched to a ThreadLocal<DocumentBuilder>.

Added tests for both issues and verified
against the pre-fix code to confirm they reproduce the original bugs.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant