| Index: components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
|
| diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
|
| index b20f810d38db52a1c8b3a339b33f36ba29880659..d5692111472ff7eb7ab9d1397cc3a7e0fce5108c 100644
|
| --- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
|
| +++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
|
| @@ -256,6 +256,7 @@ final class CronetUrlRequest implements UrlRequest {
|
| throw new IllegalArgumentException(
|
| "ByteBuffer is already full.");
|
| }
|
| + Preconditions.checkDirect(buffer);
|
|
|
| if (!mWaitingOnRead) {
|
| throw new IllegalStateException("Unexpected read attempt.");
|
| @@ -276,21 +277,16 @@ final class CronetUrlRequest implements UrlRequest {
|
| // Still waiting on read. This is just to have consistent
|
| // behavior with the other error cases.
|
| mWaitingOnRead = true;
|
| - // Since accessing byteBuffer's memory failed, it's presumably
|
| - // not a direct ByteBuffer.
|
| - throw new IllegalArgumentException(
|
| - "byteBuffer must be a direct ByteBuffer.");
|
| + throw new IllegalArgumentException("Unable to call native read");
|
| }
|
| }
|
| }
|
|
|
| @Override
|
| public void readNew(ByteBuffer buffer) {
|
| + Preconditions.checkHasRemaining(buffer);
|
| + Preconditions.checkDirect(buffer);
|
| synchronized (mUrlRequestAdapterLock) {
|
| - if (!buffer.hasRemaining()) {
|
| - throw new IllegalArgumentException("ByteBuffer is already full.");
|
| - }
|
| -
|
| if (!mWaitingOnRead) {
|
| throw new IllegalStateException("Unexpected read attempt.");
|
| }
|
| @@ -305,9 +301,7 @@ final class CronetUrlRequest implements UrlRequest {
|
| // Still waiting on read. This is just to have consistent
|
| // behavior with the other error cases.
|
| mWaitingOnRead = true;
|
| - // Since accessing byteBuffer's memory failed, it's presumably
|
| - // not a direct ByteBuffer.
|
| - throw new IllegalArgumentException("byteBuffer must be a direct ByteBuffer.");
|
| + throw new IllegalArgumentException("Unable to call native read");
|
| }
|
| }
|
| }
|
|
|