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 6ec5b8daa18d8cb62100aeb438ee940b207c9f3f..70fd10037eb9a482c8be356ed66b9e7387ea468c 100644 |
--- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java |
+++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java |
@@ -236,6 +236,7 @@ final class CronetUrlRequest implements UrlRequest { |
throw new IllegalArgumentException( |
"ByteBuffer is already full."); |
} |
+ Preconditions.checkDirect(buffer); |
if (!mWaitingOnRead) { |
throw new IllegalStateException("Unexpected read attempt."); |
@@ -256,21 +257,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."); |
} |
@@ -285,9 +281,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"); |
} |
} |
} |