Bug 1346235 - Part 2: Translate memory error to I/O failure. r=jchen, a=gchang
authorJohn Lin <jolin@mozilla.com>
Fri, 17 Mar 2017 15:04:26 +0800
changeset 393528 14fd7f066eb943604aa8d43cd8758f208617003d
parent 393527 fb9caf2d4e40ef97ac58edd9e6674109469283c3
child 393529 6e00d34c16e72c7a3a5adfc6ae037c62a90c68df
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, gchang
bugs1346235
milestone54.0a2
Bug 1346235 - Part 2: Translate memory error to I/O failure. r=jchen, a=gchang 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();