diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java index 579cc0ea..e1bd0f28 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java @@ -25,5 +25,6 @@ public interface ReplicaSessionInterceptor { void onConnected(ReplicaSession session); // The behavior when rpc session is sending a message. + // @returns false if this message shouldn't be sent. boolean onSendMessage(ReplicaSession session, final ReplicaSession.RequestEntry entry); } diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java index 048f4a82..817bb021 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java @@ -41,10 +41,11 @@ public void onConnected(ReplicaSession session) { } public boolean onSendMessage(ReplicaSession session, final ReplicaSession.RequestEntry entry) { - boolean ret = true; for (ReplicaSessionInterceptor interceptor : interceptors) { - ret &= interceptor.onSendMessage(session, entry); + if (!interceptor.onSendMessage(session, entry)) { + return false; + } } - return ret; + return true; } }