diff --git a/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java b/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
index 1b562a4a525..3e7a285793a 100644
--- a/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
+++ b/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
@@ -154,12 +154,7 @@ public final class BasicMessageChannel {
handler.onMessage(codec.decodeMessage(message), new Reply() {
@Override
public void reply(T reply) {
- try {
- callback.reply(codec.encodeMessage(reply));
- } catch (RuntimeException e) {
- Log.e(TAG + name, "Failed to encode reply", e);
- callback.reply(null);
- }
+ callback.reply(codec.encodeMessage(reply));
}
});
} catch (RuntimeException e) {
diff --git a/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java b/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
index 846cd1e0be5..9257bb83124 100644
--- a/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
+++ b/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
@@ -17,8 +17,8 @@ public interface BinaryMessenger {
* Sends a binary message to the Flutter application.
*
* @param channel the name {@link String} of the logical channel used for the message.
- * @param message the message payload, a {@link ByteBuffer} with the message bytes between position
- * zero and current position, or null.
+ * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message bytes
+ * between position zero and current position, or null.
*/
void send(String channel, ByteBuffer message);
@@ -28,8 +28,8 @@ public interface BinaryMessenger {
*
Any uncaught exception thrown by the reply callback will be caught and logged.
*
* @param channel the name {@link String} of the logical channel used for the message.
- * @param message the message payload, a {@link ByteBuffer} with the message bytes between position
- * zero and current position, or null.
+ * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message bytes
+ * between position zero and current position, or null.
* @param callback a {@link BinaryReply} callback invoked when the Flutter application responds to the
* message, possibly null.
*/
@@ -79,8 +79,8 @@ public interface BinaryMessenger {
/**
* Handles the specified reply.
*
- * @param reply the reply payload, a {@link ByteBuffer} or null. Senders of outgoing
- * replies must place the reply bytes between position zero and current position.
+ * @param reply the reply payload, a direct-allocated {@link ByteBuffer} or null. Senders of
+ * outgoing replies must place the reply bytes between position zero and current position.
* Reply receivers can read from the buffer directly.
*/
void reply(ByteBuffer reply);
diff --git a/shell/platform/android/io/flutter/plugin/common/EventChannel.java b/shell/platform/android/io/flutter/plugin/common/EventChannel.java
index 266e0c7f834..c944233728b 100644
--- a/shell/platform/android/io/flutter/plugin/common/EventChannel.java
+++ b/shell/platform/android/io/flutter/plugin/common/EventChannel.java
@@ -91,13 +91,8 @@ public final class EventChannel {
/**
* Handles a request to set up an event stream.
*
- *
Any uncaught exception thrown by this method, or the preceding arguments
- * decoding, will be caught by the channel implementation and logged. An error result
- * message will be sent back to Flutter.
- *
- *
Any uncaught exception thrown during encoding an event or error submitted to the
- * {@link EventSink} is treated similarly: the exception is logged, and an error event
- * is sent to Flutter.
+ *
Any uncaught exception thrown by this method will be caught by the channel
+ * implementation and logged. An error result message will be sent back to Flutter.
*
* @param arguments stream configuration arguments, possibly null.
* @param events an {@link EventSink} for emitting events to the Flutter receiver.
@@ -107,9 +102,8 @@ public final class EventChannel {
/**
* Handles a request to tear down an event stream.
*
- *
Any uncaught exception thrown by this method, or the preceding arguments
- * decoding, will be caught by the channel implementation and logged. An error result
- * result message will be sent back to Flutter.
+ *
Any uncaught exception thrown by this method will be caught by the channel
+ * implementation and logged. An error result message will be sent back to Flutter.
*
* @param arguments stream configuration arguments, possibly null.
*/
@@ -156,18 +150,13 @@ public final class EventChannel {
@Override
public void onMessage(ByteBuffer message, final BinaryReply reply) {
- try {
- final MethodCall call = codec.decodeMethodCall(message);
- if (call.method.equals("listen")) {
- onListen(call.arguments, reply);
- } else if (call.method.equals("cancel")) {
- onCancel(call.arguments, reply);
- } else {
- reply.reply(null);
- }
- } catch (RuntimeException e) {
- Log.e(TAG + name, "Failed to decode event stream lifecycle call", e);
- reply.reply(codec.encodeErrorEnvelope("decode", e.getMessage(), null));
+ final MethodCall call = codec.decodeMethodCall(message);
+ if (call.method.equals("listen")) {
+ onListen(call.arguments, reply);
+ } else if (call.method.equals("cancel")) {
+ onCancel(call.arguments, reply);
+ } else {
+ reply.reply(null);
}
}
@@ -180,7 +169,7 @@ public final class EventChannel {
} catch (RuntimeException e) {
activeSink.set(null);
Log.e(TAG + name, "Failed to open event stream", e);
- callback.reply(codec.encodeErrorEnvelope("uncaught", e.getMessage(), null));
+ callback.reply(codec.encodeErrorEnvelope("error", e.getMessage(), null));
}
} else {
callback.reply(codec.encodeErrorEnvelope("error", "Stream already active", null));
@@ -195,7 +184,7 @@ public final class EventChannel {
callback.reply(codec.encodeSuccessEnvelope(null));
} catch (RuntimeException e) {
Log.e(TAG + name, "Failed to close event stream", e);
- callback.reply(codec.encodeErrorEnvelope("uncaught", e.getMessage(), null));
+ callback.reply(codec.encodeErrorEnvelope("error", e.getMessage(), null));
}
} else {
callback.reply(codec.encodeErrorEnvelope("error", "No active stream to cancel", null));
@@ -210,12 +199,7 @@ public final class EventChannel {
if (hasEnded.get() || activeSink.get() != this) {
return;
}
- try {
- EventChannel.this.messenger.send(name, codec.encodeSuccessEnvelope(event));
- } catch (RuntimeException e) {
- Log.e(TAG + name, "Failed to encode event", e);
- EventChannel.this.messenger.send(name, codec.encodeErrorEnvelope("encode", e.getMessage(), null));
- }
+ EventChannel.this.messenger.send(name, codec.encodeSuccessEnvelope(event));
}
@Override
@@ -223,14 +207,9 @@ public final class EventChannel {
if (hasEnded.get() || activeSink.get() != this) {
return;
}
- try {
- EventChannel.this.messenger.send(
- name,
- codec.encodeErrorEnvelope(errorCode, errorMessage, errorDetails));
- } catch (RuntimeException e) {
- Log.e(TAG + name, "Failed to encode error", e);
- EventChannel.this.messenger.send(name, codec.encodeErrorEnvelope("encode", e.getMessage(), null));
- }
+ EventChannel.this.messenger.send(
+ name,
+ codec.encodeErrorEnvelope(errorCode, errorMessage, errorDetails));
}
@Override
diff --git a/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java b/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java
index d534b209ef6..ab284c9753b 100644
--- a/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java
+++ b/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java
@@ -26,7 +26,12 @@ public final class JSONMessageCodec implements MessageCodec
*
- *
Any uncaught exception thrown by this method, or the preceding method call decoding, will be
- * caught by the channel implementation and logged, and an error result will be sent back to Flutter.
- *
- *
Any uncaught exception thrown during encoding a result submitted to the {@link Result}
- * is treated similarly: the exception is logged, and an error result is sent to Flutter.
+ *
Any uncaught exception thrown by this method will be caught by the channel implementation and
+ * logged, and an error result will be sent back to Flutter.