Skip to content

okhttp auto config for spring boot 2 and 3 - #6139

Open
lbloder wants to merge 7 commits into
feat/okhttp-autoconfiguration-boot-4from
okhttp-autoconfiguration-boot-3-2
Open

lbloder wants to merge 7 commits into
feat/okhttp-autoconfiguration-boot-4from
okhttp-autoconfiguration-boot-3-2

Conversation

@lbloder

@lbloder lbloder commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

#skip-changelog

📜 Description

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

@sentry

sentry Bot commented Sep 21, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.57.0 (1) release

⚙️ sentry-android Build Distribution Settings

@lbloder

lbloder commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@lbloder

lbloder commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@sentry review

@lbloder
lbloder marked this pull request as ready for review September 21, 2026 15:34
Comment on lines +77 to +78
try (Response response = okHttpClient.newCall(request).execute()) {
return objectMapper.readValue(response.body().byteStream(), Todo.class);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The code does not check if response.body() is null before calling .byteStream(), which can lead to a NullPointerException.
Severity: LOW

Suggested Fix

Add a null check on the ResponseBody object returned by response.body() before attempting to access its methods. If the body is null, handle the case appropriately, for instance, by throwing an IOException or returning an empty or error response.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
sentry-samples/sentry-samples-spring-boot-jakarta/src/main/java/io/sentry/samples/spring/boot/jakarta/TodoController.java#L77-L78

Potential issue: The code in `TodoController.java` makes a call to an external service
using OkHttp. The result of `response.body()` can be `null` in certain situations, such
as when a response is served from a cache. The code directly calls `.byteStream()` on
the result of `response.body()` without a null check. If `response.body()` returns
`null`, this will cause a `NullPointerException`. The surrounding `try-catch` block only
catches `IOException`, so the `NullPointerException` will be unhandled, causing the
request to fail.

Also affects:

  • sentry-samples/sentry-samples-spring-boot/src/main/java/io/sentry/samples/spring/boot/TodoController.java:53~54

Did we get this right? 👍 / 👎 to inform future reviews.

This branch has not been deployed

No deployments
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.

1 participant