Files
floci/src/main/java/io/github
Priamo Germosen 7505110ed9 feat(msk): add configuration revision actions (#2344)
* fix(core): extract shared pagination helper, reject maxResults=0

Closes #2339, #2340.

ListResult<T> and its paginate()/encode()/decode() helpers existed as
five near-identical private copies (BedrockAgentCoreGatewayService,
BedrockAgentCoreIdentityService, BedrockAgentCoreMemoryService,
BedrockAgentCoreControlService's three list methods, and MskService),
not the two originally scoped in #2340 - the ListResult<T> record was
already shared within bedrockagentcorecontrol, which is what earlier
scoping missed. Extracts core.common.Pagination + PaginatedResult<T>
and migrates every one of them, deleting both now-unused per-service
ListResult model classes.

Every duplicate collapsed "maxResults omitted" and "maxResults=0"
onto the same primitive int, defaulting both to the full page instead
of rejecting the explicit zero the way AWS's MaxResults min:1
constraint requires (confirmed against botocore's real kafka and
verified live: botocore itself refuses to send MaxResults=0
client-side). Pagination.paginate/parseMaxResults take a boxed
Integer so the two cases are distinguishable, and every migrated
service now rejects 0 with its own existing error code
(ValidationException for the bedrockagentcorecontrol services,
BadRequestException for MSK) - the fix lands once, not five times.

Also carries over the MskController fix from #2336: an
Integer-typed @QueryParam converts before the resource method runs,
so a non-numeric maxResults was a bare 404 instead of an AWS-shaped
400. Every migrated REST controller now binds maxResults as a String
and calls Pagination.parseMaxResults, closing the same gap in
BedrockAgentCoreGatewayController/ControlController/MemoryController
that MSK already had fixed.

* feat(msk): add configuration revision actions

Closes #2338.

Adds UpdateConfiguration, ListConfigurationRevisions, and
DescribeConfigurationRevision, the three actions #2299 explicitly
scoped out ("a separate follow-up issue"). MskConfiguration now
stores a full revision history (revisions + serverPropertiesByRevision
keyed by revision number) instead of a single latest-revision field -
UpdateConfiguration appends rather than overwrites, and
DescribeConfigurationRevision is the only action that returns
serverProperties (base64), matching AWS's real shapes: Configuration/
DescribeConfigurationResponse/CreateConfigurationResponse never
include it, verified against botocore's kafka service model the same
way as #2336/#2343 rather than trusting the docs page.

ListConfigurationRevisions builds on the shared Pagination.paginate
helper from #2343 (cursor = zero-padded revision number) instead of
introducing a sixth duplicate of that logic.

getLatestRevision() is now derived from the revision list rather than
a separately-stored field, so it can never drift out of sync with it.

* fix(msk): guard configuration schema upgrade and update-race in UpdateConfiguration

Old (pre-revision-history) persisted configurations have latestRevision/
serverProperties keys this class no longer maps, which previously threw and
failed the entire msk-configurations.json load; ignore them instead and
reject updates against such an entry with a 400 rather than NPE-ing.

Also serialize UpdateConfiguration's read-modify-write behind a lock so two
concurrent updates for the same ARN can no longer derive the same revision
number and silently overwrite each other's serverProperties.

* fix(msk): stop leaking mutable revision state through getters

MskConfiguration#getRevisions/getServerPropertiesByRevision returned the
live internal List/Map, which is why MskService#updateConfiguration was
mutating through them directly - and in an order (revision appended,
then its properties inserted) that let an unsynchronized reader observe
a revision with no server properties yet and NPE on Base64-encoding it.

Add MskConfiguration#addRevision to own both writes in the safe order,
and have the getters return copies so callers can no longer bypass it.

* fix(msk): guard revision reads with the same lock updateConfiguration writes under

listConfigurationRevisions/describeConfigurationRevision read revisions
and serverPropertiesByRevision - plain, non-thread-safe collections -
without holding configurationUpdateLock, so a concurrent updateConfiguration
could race the reader's iteration/copy, not just return stale data.

* fix(msk): close remaining unsynchronized-read races on configuration revisions

Two more gaps in the same family as the last fix:

- deleteConfiguration didn't take configurationUpdateLock, so it could
  race updateConfiguration and get resurrected by the update's trailing
  put(arn, ...) after the delete already removed the entry.
- getLatestRevision() is read directly from MskController with no access
  to the service's lock at all, so no per-call-site synchronized block
  can close that gap. Make revisions/serverPropertiesByRevision
  CopyOnWriteArrayList/ConcurrentHashMap instead, so every current and
  future reader is safe by construction rather than by remembering to
  take a lock it may not have access to.

* fix(msk): migrate pre-revision-history configurations onto revision 1

A configuration persisted before this PR's schema change stored a single
"latestRevision" object plus a flat "serverProperties" string. Those keys
were only being swallowed by ignoreUnknown, so the entry loaded with an
empty revision list and getLatestRevision() == null. AWS marks
Configuration's LatestRevision required, and toConfigurationView builds
into a HashMap - which keeps a key with a null value, unlike Map.of - with
no NON_NULL inclusion configured anywhere in the application. So
DescribeConfiguration and ListConfigurations emitted a required member as
an explicit "latestRevision": null for those entries, and
UpdateConfiguration rejected them permanently.

Map both old keys back onto revision 1 at load time instead. The data was
always still there, so this is a migration rather than a degradation, and
it un-breaks UpdateConfiguration for those configurations as well.

- The setters are deserialize-only: @JsonSetter is an explicit marker, so
  it survives the @JsonIgnore split on getLatestRevision() without
  re-enabling the write side. The old shape is read, never written back.
- Jackson calls the two setters in whatever order the keys sit in the
  file, so neither can assemble the revision alone; each buffers its half
  and the pair completes the migration.
- A legacy entry with no serverProperties migrates to an empty string, not
  null: serverPropertiesByRevision is a ConcurrentHashMap, which rejects
  null values, and DescribeConfigurationRevision base64-encodes what it
  finds without a null check.
- The updateConfiguration guard stays, now covering only an entry with no
  revision data at all rather than every pre-schema configuration.

Also corrects the comment in listConfigurationRevisions, which still
justified its lock by calling the collections plain and non-concurrent.
That was true when it was written but stopped being true in 93bc30e7; the
lock is kept, for consistency with describeConfigurationRevision reading
both collections, not to prevent a torn read.

Verified locally: MskServiceTest 34, MskControllerTest 2,
MskControllerIntegrationTest 20 - 0 failures, 0 errors. Reverting only the
MskConfiguration change fails 6 of the new tests, confirming they bite.
2026-08-19 21:53:33 -05:00
..