GH-1683 - Return persisted status from JpaEventPublicationAdapter#getStatus#1714
Open
BK202503 wants to merge 9 commits into
Open
GH-1683 - Return persisted status from JpaEventPublicationAdapter#getStatus#1714BK202503 wants to merge 9 commits into
BK202503 wants to merge 9 commits into
Conversation
…rnalization. To ensure proper ordering of messages externalized via the outbox, we now block the generic execution that returns a CompletableFuture. Co-Authored-By: Roland Beisel <info@rolandbeisel.de>
Signed-off-by: SAY-5 <saiasish.cnp@gmail.com>
…ion for database-related slice test annotations.
81b1923 to
4647796
Compare
…tionAdapter#getStatus Currently the JPA adapter derives the status from `completionDate` alone, returning either COMPLETED or PUBLISHED. As a result, publications that were marked FAILED (or RESUBMITTED) by `markFailed` / `markResubmitted` — both of which already write the correct value into the `status` column — appear as PUBLISHED when read back through `getStatus()`. Mirror the JdbcEventPublicationRepositoryV2 adapter: return the persisted `status` when set, falling back to the previous derivation (with PROCESSING as the default, matching the JPA entity's own constructor) when older rows have a null status column. The added integration test demonstrates the bug — without the fix it returns PUBLISHED after `markFailed` — and clears the persistence context between the JPQL update and the re-read so the test loads a fresh entity. Signed-off-by: BK202503 <199436087+BK202503@users.noreply.github.com>
4647796 to
639eabd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1683.
Problem
JpaEventPublicationAdapter#getStatus()ignores the persistedstatuscolumn and derives the value purely fromcompletionDate:So a publication that was correctly marked FAILED (via
markFailed) or RESUBMITTED (viamarkResubmitted) — both of which write the right value into thestatuscolumn — still appears as PUBLISHED throughgetStatus(). The status persisted on the entity, the status reported by the API, and the status the repository'scountByStatusqueries operate on are out of sync.Fix
Mirror what
JdbcEventPublicationRepositoryV2's adapter already does (lines 768-775 ofJdbcEventPublicationRepositoryV2.java): return the persistedstatusfield when it is non-null, and fall back to the previous derivation for rows where the column may have been written before the field existed.The fallback uses
Status.PROCESSINGrather thanStatus.PUBLISHEDbecause:JpaEventPublication's constructor itself usesPROCESSINGas its default when status is null and nocompletionDateis set, so this restores consistency.JdbcEventPublicationRepositoryV2already usesPROCESSINGfor the same fallback.Test
Added
exposesPersistedStatusOnReloadnext to the existingmarkFailedtests. Without the fix it fails withexpected: FAILED but was: PUBLISHED. The test clears the persistence context between the JPQL-basedmarkFailedand the re-read so that we load a fresh entity from the database rather than the cached in-memory one — which is the production scenario (findIncompletePublicationsis called from a separate transaction).Local result with the fix applied:
Scope
spring-modulith-events-jpa(1 source change, 1 test added). The MongoDB / Neo4j adapters use different status accessors and the JDBC v2 adapter is already correct.statuscolumn already exists onJpaEventPublication.Looking forward to feedback. I had to sign the CLA on my first contribution — let me know if anything's missing on that side.