Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException on commonCompleteSegmentByteCount #1392

Closed
vitorpamplona opened this issue Dec 14, 2023 · 4 comments
Closed

NullPointerException on commonCompleteSegmentByteCount #1392

vitorpamplona opened this issue Dec 14, 2023 · 4 comments

Comments

@vitorpamplona
Copy link

Looks like there is a possible NPE in commonCompleteSegmentByteCount.

I can't reproduce this bug but this is a PlayStore stack from an Xperia 5 II running Android 12 (SDK 31)

Exception java.lang.NullPointerException:
  at okio.internal.-Buffer.commonCompleteSegmentByteCount (-Buffer.java)
  at okio.Buffer.completeSegmentByteCount (Buffer.kt)
  at okio.RealBufferedSink.emitCompleteSegments (RealBufferedSink.kt)
  at okio.DeflaterSink.deflate (DeflaterSink.kt)
  at okio.DeflaterSink.finishDeflate$okio (DeflaterSink.kt)
  at okio.DeflaterSink.close (DeflaterSink.kt)
  at okhttp3.internal.ws.MessageDeflater.close (MessageDeflater.kt)
  at okhttp3.internal.ws.WebSocketWriter.close (WebSocketWriter.kt)
  at okhttp3.internal._UtilCommonKt.closeQuietly (-UtilCommon.kt)
  at okhttp3.internal.ws.RealWebSocket.failWebSocket (RealWebSocket.kt)
  at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse (RealWebSocket.kt)
  at okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
  at java.lang.Thread.run (Thread.java:1012)

The code is using versions:

  • com.squareup.okhttp3:okhttp:5.0.0-alpha.11
  • com.squareup.okio:okio-jvm:3.6.0
  • com.squareup.okio:okio:3.6.0
@swankjesse
Copy link
Member

@vitorpamplona is it possible you’re operating on your Okio streams from multiple threads concurrently? Concurrent modifications can trigger errors like this.

@swankjesse
Copy link
Member

Oooh, actually it’s OkHttp to blame for exactly that, and that bug is very recently fixed.
square/okhttp#8121

Will ship a new OkHttp 5.0 alpha very soon with that fix.

@vitorpamplona
Copy link
Author

I don't use okio streams directly. I just used them through OkHttp. I assume OkHttp takes care of the thread handling part.

Do I need to take additional protections when multithreading?

@vitorpamplona
Copy link
Author

Thank you! ☺️

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

No branches or pull requests

2 participants