Skip to content

fix(java): add warning in replaceAllObjects for empty objects - #6607

Merged
eric-zaharia merged 1 commit into
mainfrom
fix/java-replace-warning
Jun 26, 2026
Merged

eric-zaharia merged 1 commit into
mainfrom
fix/java-replace-warning

Conversation

@eric-zaharia

@eric-zaharia eric-zaharia commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

🧭 What and Why

🎟 JIRA Ticket: API-500

Stemming from CR-11510: a customer wiped an index by calling replaceAllObjects with an empty list. The helper copies the source index's settings/synonyms/rules to a temp index, batches zero records into it, then moves the temp index over the source — leaving the original index empty. This happened silently, with no warning.

This adds a warning-level log when replaceAllObjects (and its replaceAllObjectsWithTransformation sibling) is called with an empty list of objects. Behavior is unchanged — the call still proceeds; it only warns.

This is the Java client; the other clients are handled in their own PRs.

Changes included:

  • Log a WARNING (via java.util.logging) when the objects collection is empty, added to the canonical replaceAllObjects and replaceAllObjectsWithTransformation implementations. All overloads delegate down to these, so every call path is covered: replaceAllObjects was called with an empty list of objects, which will delete all records currently in the "<indexName>" index.
  • The empty check uses Collection.isEmpty() when possible and falls back to iterator().hasNext() for non-Collection Iterables, so single-use iterables aren't consumed by the check.
  • Add a Warning note to the replaceAllObjects Javadoc so the behavior surfaces in IDE hover/autocomplete at write-time.

Out of scope

  • The public "Replace all records" documentation page lives in the docs-new repo and is updated separately.

🧪 Test

  • Regenerated the Java search client and compiled it (:algoliasearch:compileJava --rerun-tasks → BUILD SUCCESSFUL).
  • No CTS changes: this only adds a log line and doesn't alter requests or behavior.

@eric-zaharia eric-zaharia self-assigned this Jun 26, 2026
@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

💥 Breaking changes detected !!

Either this PR or a previous PR not released yet introduced breaking changes, be careful when merging.
You can find the details in the 'client java@21' CI job.

✔️ Code generated!

Name Link
🪓 Triggered by 3ce94df6b7f053ec00c8666257f014d351fc2441
🍃 Generated commit bebc5c2e6c9923cfc0fa8a93171fe926005c3b5e
🌲 Generated branch generated/fix/java-replace-warning
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
java 1139

@eric-zaharia
eric-zaharia marked this pull request as ready for review June 26, 2026 08:07
@eric-zaharia
eric-zaharia requested a review from a team as a code owner June 26, 2026 08:07

@Fluf22 Fluf22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good

@eric-zaharia
eric-zaharia merged commit cbb201d into main Jun 26, 2026
19 checks passed
@eric-zaharia
eric-zaharia deleted the fix/java-replace-warning branch June 26, 2026 08:18
algolia-api-clients-automation-bot Bot added a commit that referenced this pull request Jun 26, 2026
… (generated) [skip ci]

Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-java that referenced this pull request Jun 26, 2026
…ted)

algolia/api-clients-automation#6607

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
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