Skip to content

Fix NPE in XMLConnector.dispose() when init() failed#90

Merged
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:copilot/fix-null-pointer-exception
May 13, 2026
Merged

Fix NPE in XMLConnector.dispose() when init() failed#90
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:copilot/fix-null-pointer-exception

Conversation

@vharseko
Copy link
Copy Markdown
Member

@vharseko vharseko commented May 8, 2026

When XMLConnector.init() fails (e.g. invalid XML/XSD path), the framework still invokes dispose(), which dereferences the never-assigned xmlInstanceHandler and throws an NPE that masks the original failure cause from test/operation calls.

Changes

  • XMLConnector.dispose(): guard against xmlInstanceHandler == null, log at ok level and return instead of throwing.
  • Idempotency: null out xmlInstanceHandler in a finally after dispose() so repeated calls are safe (consistent with ConcurrentXMLHandler.dispose() decrementing invokers).
  • Logging: guard the config.getXmlFilePath() access so a pre-init dispose can't NPE either.
public void dispose() {
    if (xmlInstanceHandler == null) {
        log.ok("Dispose called but XML handler was not initialized; nothing to release");
        return;
    }
    try {
        xmlInstanceHandler.dispose();
    } finally {
        xmlInstanceHandler = null;
    }
    log.ok("Dispose {0}", config != null ? config.getXmlFilePath() : null);
}

@vharseko vharseko requested a review from maximthomas May 8, 2026 16:10
Copy link
Copy Markdown
Contributor

@maximthomas maximthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls update

@vharseko vharseko merged commit 53d1fd7 into OpenIdentityPlatform:master May 13, 2026
16 of 17 checks passed
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.

3 participants