Skip to content

Lazy Initialisation of ExternalIdentityMonitor#2928

Draft
Shivam-Agg wants to merge 3 commits into
apache:trunkfrom
Shivam-Agg:trunk
Draft

Lazy Initialisation of ExternalIdentityMonitor#2928
Shivam-Agg wants to merge 3 commits into
apache:trunkfrom
Shivam-Agg:trunk

Conversation

@Shivam-Agg

Copy link
Copy Markdown

No description provided.

@Shivam-Agg Shivam-Agg changed the title Lazy Initialization of ExternalIdentityMonitor OAK-10578: Lazy Initialisation of ExternalIdentityMonitor Jun 4, 2026
@Shivam-Agg Shivam-Agg changed the title OAK-10578: Lazy Initialisation of ExternalIdentityMonitor Lazy Initialisation of ExternalIdentityMonitor Jun 4, 2026
log.debug("No ExternalIdentityMonitor registered.");
monitor = ExternalIdentityMonitor.NOOP;
}
monitorSupplier = () -> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oak-auth-external enforces 100% branch coverage (mvn verify -pl oak-auth-external -Pcoverage passes on trunk but fails on this PR at 0.9). The supplier's cached monitor != null branch is never exercised because each call site invokes get() only once—please add a test that hits the supplier twice in one login.

}

@Test
public void testMonitorResolvedExactlyOnceOnSuccessfulSync() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This largely duplicates testSyncUser (same IDP/sync setup) while only asserting track once. Consider folding verify(wb, times(1)).track(ExternalIdentityMonitor.class) into testSyncUser and removing this test.

timer.mark("commit");
log.debug("validateUser({}) {}", id, timer);
monitor.doneSyncId(watch.elapsed(NANOSECONDS), syncResult);
monitorSupplier.get().doneSyncId(watch.elapsed(NANOSECONDS), syncResult);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

validateUser now resolves the monitor lazily via monitorSupplier.get().doneSyncId(...). Consider asserting never().track right after initialize() and times(1) after login() in testValidateUser so this path documents the same lazy contract as the new sync tests.

}

@Test
public void testNoopMonitorUsedWhenMonitorNotRegistered() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Login succeeds and track runs once, but the test does not show ExternalIdentityMonitor.NOOP was selected. Consider stronger assertions (sync side effects) or a failure-path variant without a registered monitor for syncFailed.

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.

2 participants