Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Send UI Profiling app start chunk when it finishes ([#4423](https://github.com/getsentry/sentry-java/pull/4423))
- Republish Javadoc [#4457](https://github.com/getsentry/sentry-java/pull/4457)
- Finalize `OkHttpEvent` even if no active span in `SentryOkHttpInterceptor` [#4469](https://github.com/getsentry/sentry-java/pull/4469)

## 8.13.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class SentryOkHttpEvent(private val scopes: IScopes, private val reques
internal val callSpan: ISpan?
private var response: Response? = null
private var clientErrorResponse: Response? = null
private val isEventFinished = AtomicBoolean(false)
internal val isEventFinished = AtomicBoolean(false)
private var url: String
private var method: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public open class SentryOkHttpInterceptor(

private fun finishSpan(span: ISpan?, request: Request, response: Response?, isFromEventListener: Boolean, okHttpEvent: SentryOkHttpEvent?) {
if (span == null) {
okHttpEvent?.finish()
Comment thread
romtsn marked this conversation as resolved.
Comment thread
romtsn marked this conversation as resolved.
return
}
if (beforeSpan != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,15 @@ class SentryOkHttpInterceptorTest {
val okHttpEvent = SentryOkHttpEventListener.eventMap[call]!!
assertEquals(fixture.server.url("/hello/v1").toUrl().toString(), okHttpEvent.callSpan!!.getData("url"))
}

@Test
fun `when no active http span still finalizes okHttpEvent`() {
val client = fixture.getSut(isSpanActive = false, eventListener = SentryOkHttpEventListener(fixture.scopes))
val request = getRequest("/hello/")
val call = client.newCall(request)
call.execute()

val okHttpEvent = SentryOkHttpEventListener.eventMap[call]!!
assertTrue(okHttpEvent.isEventFinished.get())
}
}
Loading