Skip to content

chore: various updates to Java codebase example#609

Merged
jeastham1993 merged 3 commits intomainfrom
feat/java-improvements
Mar 4, 2026
Merged

chore: various updates to Java codebase example#609
jeastham1993 merged 3 commits intomainfrom
feat/java-improvements

Conversation

@jeastham1993
Copy link
Copy Markdown
Collaborator

What does this PR do?

Motivation

Testing Guidelines

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@jeastham1993
Copy link
Copy Markdown
Collaborator Author

@codex could you review this PR p[lease?

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +269 to +270
var inventoryItem = this.repository.withProductId(productId);
inventoryItem.reserveStockFor(orderNumber);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +26 to +28
if (!result.isSuccess()) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(result)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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>
@jeastham1993 jeastham1993 merged commit f9f1c62 into main Mar 4, 2026
13 checks passed
@jeastham1993 jeastham1993 deleted the feat/java-improvements branch March 4, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant