Skip to content

GH-11248: Make METADATA_VALUE NOT NULL in JdbcMetadataStore schemas - #11259

Merged
artembilan merged 2 commits into
spring-projects:mainfrom
kalayciburak:GH-11248-metadata-value-not-null
Aug 11, 2026
Merged

GH-11248: Make METADATA_VALUE NOT NULL in JdbcMetadataStore schemas#11259
artembilan merged 2 commits into
spring-projects:mainfrom
kalayciburak:GH-11248-metadata-value-not-null

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Fixes: gh-11248

Summary

JdbcMetadataStore.putIfAbsent() treats a successful read of a SQL NULL METADATA_VALUE as "insert succeeded" (return null), so a null-valued row can make callers (e.g. MetadataStoreSelector) believe a value was stored when it was not.

Per maintainer guidance on the issue, this change makes METADATA_VALUE NOT NULL in all shipped schema-*.sql scripts for 7.2.0 and documents the non-null contract on JdbcMetadataStore. The store API already rejects null values via Assert.notNull; the schema now matches that contract.

Existing databases created with older scripts should migrate the column to NOT NULL (and remove any null-valued rows) when upgrading.

Test plan

  • ./gradlew :spring-integration-jdbc:test --tests org.springframework.integration.jdbc.metadata.JdbcMetadataStoreTests (12/12)
  • ./gradlew :spring-integration-jdbc:checkstyleMain :spring-integration-jdbc:checkstyleTest

@lsh1215

lsh1215 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up — I opened gh-11248.

One case I want to make sure I understand: the NOT NULL applies only to tables created from the new scripts. On a table created by an older script the column stays nullable, so a row with a null value can still exist — the insert affects 0 rows, queryForObject() returns that null instead of throwing, and putIfAbsent() reports it as stored. That's the case I filed.

@artembilan, did "react respectively in the JdbcMetadataStore" include a guard for that, or are tables from older scripts out of scope here? Either way works for me — just wanted to ask while the PR is open.

Minor: jdbc/metadata-store.adoc still shows the DDL with a nullable METADATA_VALUE.

@kalayciburak

Copy link
Copy Markdown
Contributor Author

yeah — older schemas are out of scope for a runtime guard here. Artem's note was basically "don't let null into the DB": NOT NULL on the shipped scripts + the existing Assert.notNull on put/putIfAbsent. Upgrade path is drop null rows and alter the column (same as the class javadoc).

also fixed the DDL sample in jdbc/metadata-store.adoc — it still showed a nullable METADATA_VALUE.

@artembilan

Copy link
Copy Markdown
Member

On a table created by an older script the column stays nullable

Right. We will call this out in the Migration Guide.

We probably need to double check the logic in that putIfAbsent() what is the reaction for the null.

Thanks

…Store schemas

Reject null metadata values at the schema level so putIfAbsent cannot
misinterpret a null-valued row as a successful insert. Document the
non-null contract (including metadata-store.adoc DDL) and cover it with
focused tests.

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@kalayciburak
kalayciburak force-pushed the GH-11248-metadata-value-not-null branch from f9be522 to 390e462 Compare August 11, 2026 16:45
@kalayciburak

Copy link
Copy Markdown
Contributor Author

on putIfAbsent: value is already Assert.notNull, so a null arg fails fast with IAE (covered by the new test). return null only means "we inserted".

if a legacy row still has a null METADATA_VALUE, the insert path sees the key, queryForObject returns null, and that can look like a successful insert — that's the bug this NOT NULL change is aimed at. new schemas can't store it; old ones need the migrate step you'll put in the Migration Guide.

also squashed + fixed DCO sign-off name mismatch on the adoc commit.

@artembilan

Copy link
Copy Markdown
Member

Thanks

also squashed

I guess that is what your AI is doing according to our CONTRIBUTING.md.
Not a first time.
The idea behind that instruction was about the first commit to open PR.
All other should be as they come for a proper change history to easier for us to review.
We squash in the end on merge.

I'll go ahead and rephrase the rule in the CONTRIBUTING.md: not a first time I hear squash confirmation on subsequent pushes 😄

@kalayciburak

Copy link
Copy Markdown
Contributor Author

got it — won't squash follow-ups. the squash was only to clean a DCO author/sign-off mismatch on the docs commit, not to hide history. next time I'll leave commits as they come and fix sign-off per commit. thanks for clarifying

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add your name to the @author list of the JdbcMetadataStoreTests.

Thank you!

----

`METADATA_VALUE` is non-null (since 7.2).
Existing databases created with older scripts should remove any null-valued rows and alter the column to `NOT NULL` when upgrading.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move this sentence to the whats-new.adoc!
Create a new section there like:

[[x7.2-jdbc-changes]]
=== JDBC Support Changes

Mention the change you've just did and add a link to the target chapter.

@Test
void putRejectsNullValue() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> this.metadataStore.put("foo", null))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No foo/bar language, please.
Might be the case that we have a lot in this class already, but that is a different story to be addressed eventually.
Let's just don't introduce more!

Move METADATA_VALUE NOT NULL note to whats-new, drop foo keys
in new tests, and add author on JdbcMetadataStoreTests.

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@kalayciburak

Copy link
Copy Markdown
Contributor Author

moved the note to whats-new under JDBC Support Changes, dropped foo keys in the new tests, and added myself to the @author list on JdbcMetadataStoreTests.

@artembilan

Copy link
Copy Markdown
Member

moved the note to whats-new...

Thanks.
You don't need to post comments about what you've done if you agree with my review.
I'll see that we are on the same page in your new commit.

Use code snippets in your comments for annotation and classes/methods.
Right no you have called that Author Software GitHub organization into our discussion 😄

See GH docs about commenting style: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

@artembilan
artembilan merged commit 260ff00 into spring-projects:main Aug 11, 2026
3 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.

JdbcMetadataStore.putIfAbsent() returns null for an existing row with a null METADATA_VALUE

3 participants