chore: various updates to Java codebase example#609
Conversation
|
@codex could you review this PR p[lease? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70de372a89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import java.util.List; | ||
|
|
||
| @Provider | ||
| public class ApiExceptionMapper implements ExceptionMapper<Exception> { |
There was a problem hiding this comment.
Preserve WebApplicationException status codes
Mapping Exception globally here causes JAX-RS WebApplicationException subclasses (for example 404/405/400 generated by the framework) to be routed into this mapper and converted to the generic 500 response path, which changes API semantics and can break clients that rely on proper HTTP status handling. Add a pass-through branch for WebApplicationException (or narrow the mapper type) so framework-defined statuses are not masked.
Useful? React with 👍 / 👎.
| var inventoryItem = this.repository.withProductId(productId); | ||
| inventoryItem.reserveStockFor(orderNumber); |
There was a problem hiding this comment.
Re-check availability before each retry reservation write
The retry path fetches a fresh item and immediately calls reserveStockFor(orderNumber) without validating getAvailableStockLevel(), so if another concurrent order consumes the last unit between the initial parallel check and this write, this code can still reserve additional stock and persist reservedStockLevel above actual availability while reporting success.
Useful? React with 👍 / 👎.
…essage body - Add opentracing-api and opentracing-util dependencies to fix missing io.opentracing packages - Remove inventory-ordering CloudEventWrapper unused GlobalTracer import - Refactor SpanLink to remove dependency on internal Datadog bootstrap API (ddtrot package); define SAMPLED_FLAG/DEFAULT_FLAGS locally - Embed DSM context in _datadog envelope of CloudEventWrapper so it travels with the message body regardless of transport header support - DatadogTelemetry gains @JsonAnyGetter/@JsonAnySetter so dd-pathway-ctx serialises flat alongside traceparent - Carrier (both modules) now wraps DatadogTelemetry/Map directly; delete unused Headers.java - CloudEventWrapper always initialises DatadogTelemetry in constructor; add getDatadog() - EventPublisherImpl calls setProduceCheckpoint before serialising so DSM context is included in the body; refactor private publish() to accept CloudEventWrapper<?> - ACL lambda consumers extract _datadog from parsed message before calling setConsumeCheckpoint - Ordering service Carrier and CloudEventWrapper updated to read _datadog from incoming SNS message body Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97aa70267b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!result.isSuccess()) { | ||
| return Response.status(Response.Status.BAD_REQUEST) | ||
| .entity(result) |
There was a problem hiding this comment.
Return 5xx when stock update fails server-side
updateStockLevel maps every unsuccessful service result to 400 Bad Request, but InventoryItemService.updateStock also returns isSuccess=false for backend/runtime failures (for example DynamoDB access errors or optimistic-lock retries exhausting), so transient server faults are reported as client input errors. That makes failures look non-retriable and breaks HTTP error semantics for callers and monitoring.
Useful? React with 👍 / 👎.
…ce condition - ApiExceptionMapper: add WebApplicationException pass-through so framework-generated 404/405/400 responses are not swallowed and converted to generic 500s - InventoryItemService.reserveStockWithRetry: re-validate getAvailableStockLevel() after fetching fresh item on every retry attempt to close the race window where a concurrent order can consume the last stock unit between the parallel availability check and the optimistic-lock write Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
Motivation
Testing Guidelines
Additional Notes
Types of Changes
Check all that apply