Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static void main(String [] args) throws Exception {
}

private ManagedChannel channel;
private Status status;

void run() throws Exception {
// Port 0 means that the operating system will pick an available port to use.
Expand Down Expand Up @@ -124,10 +125,7 @@ public void onSuccess(@Nullable HelloReply result) {

@Override
public void onFailure(Throwable t) {
Status status = Status.fromThrowable(t);
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Crybaby"));
// Cause is not transmitted over the wire..
status = Status.fromThrowable(t);
latch.countDown();
}
},
Expand All @@ -136,6 +134,9 @@ public void onFailure(Throwable t) {
if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
throw new RuntimeException("timeout!");
}
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to encourage this approach, since that requires users watching on the latch an having another thread sitting around. We shouldn't depend on the latch. We could log instead, or something like that.

Verify.verify(status.getDescription().contains("Crybaby"));
// Cause is not transmitted over the wire..
}

void asyncCall() {
Expand All @@ -151,10 +152,7 @@ public void onNext(HelloReply value) {

@Override
public void onError(Throwable t) {
Status status = Status.fromThrowable(t);
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Overbite"));
// Cause is not transmitted over the wire..
status = Status.fromThrowable(t);
latch.countDown();
}

Expand All @@ -168,6 +166,9 @@ public void onCompleted() {
if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
throw new RuntimeException("timeout!");
}
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Overbite"));
// Cause is not transmitted over the wire..
}


Expand All @@ -185,9 +186,7 @@ void advancedAsyncCall() {

@Override
public void onClose(Status status, Metadata trailers) {
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Narwhal"));
// Cause is not transmitted over the wire.
ErrorHandlingClient.this.status = status;
latch.countDown();
}
}, new Metadata());
Expand All @@ -198,6 +197,9 @@ public void onClose(Status status, Metadata trailers) {
if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
throw new RuntimeException("timeout!");
}
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Narwhal"));
// Cause is not transmitted over the wire.
}
}