Skip to content

Commit 5a29d7a

Browse files
committed
Move DOA error handling inside setOutgoingBinder().
Where it can be shared by both upcoming client handshake impls.
1 parent 4ee1584 commit 5a29d7a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

binder/src/main/java/io/grpc/binder/internal/BinderClientTransport.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ protected void handleSetupTransport(Parcel parcel) {
336336
}
337337

338338
if (!setOutgoingBinder(OneWayBinderProxy.wrap(binder, offloadExecutor))) {
339-
shutdownInternal(
340-
Status.UNAVAILABLE.withDescription("Failed to observe outgoing binder"), true);
341339
return;
342340
}
343341

binder/src/main/java/io/grpc/binder/internal/BinderServerTransport.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static BinderServerTransport create(
6666
new BinderServerTransport(
6767
executorServicePool, attributes, streamTracerFactories, binderDecorator);
6868
// TODO(jdcormie): Plumb in the Server's executor() and use it here instead.
69-
// No need to handle failure here because if 'callbackBinder' is already dead, we'll notice it
70-
// again in start() when we send the first transaction.
69+
// Ignore failure here -- start() can handle the already shutdown state.
7170
transport.setOutgoingBinder(
7271
OneWayBinderProxy.wrap(callbackBinder, transport.getScheduledExecutorService()));
7372
return transport;
@@ -84,8 +83,8 @@ public static BinderServerTransport create(
8483
public synchronized void start(ServerTransportListener serverTransportListener) {
8584
this.listenerPromise.set(serverTransportListener);
8685
if (isShutdown()) {
87-
// It's unlikely, but we could be shutdown externally between construction and start(). One
88-
// possible cause is an extremely short handshake timeout.
86+
// It's unlikely, but we could be shutdown externally between construction and start().
87+
// Cause could be an extremely short handshake timeout or a dead-on-arrival client binder.
8988
return;
9089
}
9190

binder/src/main/java/io/grpc/binder/internal/BinderTransport.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ final void setState(TransportState newState) {
283283
*
284284
* <p>Subclasses should call this as early as possible but not from a constructor.
285285
*
286-
* <p>Returns true for success, false if the process hosting 'binder' is already dead. Callers are
287-
* responsible for handling this.
286+
* <p>Returns true for success. Returns true if the process hosting 'binder' is already dead. In
287+
* the latter case, this instance will have been shutdown with an appropriate error status.
288288
*/
289289
@GuardedBy("this")
290290
protected boolean setOutgoingBinder(OneWayBinderProxy binder) {
@@ -294,6 +294,9 @@ protected boolean setOutgoingBinder(OneWayBinderProxy binder) {
294294
binder.getDelegate().linkToDeath(this, 0);
295295
return true;
296296
} catch (RemoteException re) {
297+
shutdownInternal(
298+
Status.UNAVAILABLE.withDescription("Failed to observe outgoing binder").withCause(re),
299+
true);
297300
return false;
298301
}
299302
}

0 commit comments

Comments
 (0)