Bug 1346235 - part 2: translate memory error to I/O failure. r=jchen
authorJohn Lin <jolin@mozilla.com>
Fri, 17 Mar 2017 15:04:26 +0800
changeset 348402 639a9dcab2bbef7d2ffe8b888a595145242ec1b4
parent 348401 fa8084f4f200ebb0b1649287c583e60cfa9198f3
child 348403 0dad897e64bd4ba08d167e4f9d09faea1340de0e
push id39149
push userjolin@mozilla.com
push dateMon, 20 Mar 2017 11:18:00 +0000
treeherderautoland@c4f7d0039351 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1346235
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1346235 - part 2: translate memory error to I/O failure. r=jchen MozReview-Commit-ID: F2ca0q2JQp
mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java
--- a/mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java
@@ -49,27 +49,35 @@ public final class SharedMemBuffer imple
         return mSharedMem != null ? mSharedMem.getSize() : 0;
     }
 
     @Override
     public void readFromByteBuffer(ByteBuffer src, int offset, int size) throws IOException {
         if (!src.isDirect()) {
             throw new IOException("SharedMemBuffer only support reading from direct byte buffer.");
         }
-        nativeReadFromDirectBuffer(src, mSharedMem.getPointer(), offset, size);
+        try {
+            nativeReadFromDirectBuffer(src, mSharedMem.getPointer(), offset, size);
+        } catch (NullPointerException e) {
+            throw new IOException(e);
+        }
     }
 
     private native static void nativeReadFromDirectBuffer(ByteBuffer src, long dest, int offset, int size);
 
     @Override
     public void writeToByteBuffer(ByteBuffer dest, int offset, int size) throws IOException {
         if (!dest.isDirect()) {
             throw new IOException("SharedMemBuffer only support writing to direct byte buffer.");
         }
-        nativeWriteToDirectBuffer(mSharedMem.getPointer(), dest, offset, size);
+        try {
+            nativeWriteToDirectBuffer(mSharedMem.getPointer(), dest, offset, size);
+        } catch (NullPointerException e) {
+            throw new IOException(e);
+        }
     }
 
     private native static void nativeWriteToDirectBuffer(long src, ByteBuffer dest, int offset, int size);
 
     @Override
     public void dispose() {
         if (mSharedMem != null) {
             mSharedMem.dispose();