Skip to content

Commit

Permalink
okhttp: Absorb okio 2.x API incompatibility
Browse files Browse the repository at this point in the history
okio 2.x is ABI compatible with 1.x but not API compatible. This hasn't
been a problem as users use binaries from Maven Central so the ABI
compatibility is the important part. However, when building with Bazel
the API compatibily is the important part.

Tested with okio 2.10.0

Fixes grpc#8004
  • Loading branch information
ejona86 committed Mar 22, 2021
1 parent 043c9d6 commit 557950f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ public int readableBytes() {

@Override
public int readUnsignedByte() {
return buffer.readByte() & 0x000000FF;
try {
fakeEofExceptionMethod(); // Okio 2.x can throw EOFException from readByte()
return buffer.readByte() & 0x000000FF;
} catch (EOFException e) {
throw new IndexOutOfBoundsException(e.getMessage());
}
}

private void fakeEofExceptionMethod() throws EOFException {}

@Override
public void skipBytes(int length) {
try {
Expand Down

0 comments on commit 557950f

Please sign in to comment.