fix(lifecycle): clear storage before services clear on state reset (#3388)

performReset ran every Resettable.clear() first and storageFactory
.clearAll() last. Services that re-create bootstrap state in clear()
lost it again right away. IAM Identity Center is one: after a
/_floci/state/reset its bootstrap identity store was gone, so every
SCIM call answered 401 until a restart.

This is what broke ScimIntegrationTest in CI shard 3 since #3331.
EmulatorInfoControllerIntegrationTest runs in the same test
application before it and posts the reset endpoints.

Clear storage first, then let services clear and re-seed. The clear()
implementations that iterate state to stop timers or sockets read
in-memory maps, not storage, so the order change does not affect them.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-09-10 23:47:17 -04:00
1 parent 48d2928061
commit 22bae1fcd2
2 files changed
+21 -1

No files matched your search

@@ -146,10 +146,12 @@ public class EmulatorInfoController {
}
private void performReset() {
// Storage first. Services re-create their bootstrap state in clear(), and a wipe
// afterwards would remove it again until the next restart.
storageFactory.clearAll();
for (Resettable r : resettables) {
r.clear();
}
storageFactory.clearAll();
}
static String resolveVersion() {
@@ -134,6 +134,24 @@ class EmulatorInfoControllerIntegrationTest {
.body("status", equalTo("OK"));
}
@Test
void stateReset_keepsBootstrapStateOfServicesThatReseedOnClear() {
// IAM Identity Center recreates its bootstrap instance in clear(). A reset that wiped
// storage after that step left every SCIM call answering 401 until a restart.
given()
.when().post("/_floci/state/reset")
.then()
.statusCode(200);
given()
.header("Authorization", "Bearer floci-scim-token")
.when()
.get("/9067f2a3c1-00000000-0000-0000-0000-000000000000/scim/v2/ServiceProviderConfig")
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"));
}
@Test
void stateReset_clearsDatabaseState() {
// 1. Put SSM parameter