use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project grpc-java by grpc.
the class XdsServerWrapper method internalStart.
private void internalStart() {
try {
xdsClientPool = xdsClientPoolFactory.getOrCreate();
} catch (Exception e) {
StatusException statusException = Status.UNAVAILABLE.withDescription("Failed to initialize xDS").withCause(e).asException();
listener.onNotServing(statusException);
initialStartFuture.set(statusException);
return;
}
xdsClient = xdsClientPool.getObject();
boolean useProtocolV3 = xdsClient.getBootstrapInfo().servers().get(0).useProtocolV3();
String listenerTemplate = xdsClient.getBootstrapInfo().serverListenerResourceNameTemplate();
if (!useProtocolV3 || listenerTemplate == null) {
StatusException statusException = Status.UNAVAILABLE.withDescription("Can only support xDS v3 with listener resource name template").asException();
listener.onNotServing(statusException);
initialStartFuture.set(statusException);
xdsClient = xdsClientPool.returnObject(xdsClient);
return;
}
String replacement = listenerAddress;
if (listenerTemplate.startsWith(XDSTP_SCHEME)) {
replacement = XdsClient.percentEncodePath(replacement);
}
discoveryState = new DiscoveryState(listenerTemplate.replaceAll("%s", replacement));
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project grpc-java by grpc.
the class CsdsService method handleRequest.
private boolean handleRequest(ClientStatusRequest request, StreamObserver<ClientStatusResponse> responseObserver) {
StatusException error;
try {
responseObserver.onNext(getConfigDumpForRequest(request));
return true;
} catch (StatusException e) {
error = e;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.log(Level.FINE, "Server interrupted while building CSDS config dump", e);
error = Status.ABORTED.withDescription("Thread interrupted").withCause(e).asException();
} catch (Exception e) {
logger.log(Level.WARNING, "Unexpected error while building CSDS config dump", e);
error = Status.INTERNAL.withDescription("Unexpected internal error").withCause(e).asException();
}
responseObserver.onError(error);
return false;
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project grpc-java by grpc.
the class StatusProtoTest method toStatusException.
@Test
public void toStatusException() throws Exception {
StatusException se = StatusProto.toStatusException(STATUS_PROTO);
com.google.rpc.Status extractedStatusProto = StatusProto.fromThrowable(se);
assertEquals(STATUS_PROTO.getCode(), se.getStatus().getCode().value());
assertEquals(STATUS_PROTO.getMessage(), se.getStatus().getDescription());
assertEquals(STATUS_PROTO, extractedStatusProto);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project grpc-java by grpc.
the class BinderTransport method sendOutOfBandClose.
final void sendOutOfBandClose(int callId, Status status) {
Parcel parcel = Parcel.obtain();
try {
// Placeholder for flags. Will be filled in below.
parcel.writeInt(0);
int flags = TransactionUtils.writeStatus(parcel, status);
TransactionUtils.fillInFlags(parcel, flags | TransactionUtils.FLAG_OUT_OF_BAND_CLOSE);
sendTransaction(callId, parcel);
} catch (StatusException e) {
logger.log(Level.WARNING, "Failed sending oob close transaction", e);
} finally {
parcel.recycle();
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method from_tls_clientAuthRequire_noClientCert.
@Test
public void from_tls_clientAuthRequire_noClientCert() throws Exception {
ServerCredentials serverCreds = TlsServerCredentials.newBuilder().keyManager(server1Cert, server1Key).trustManager(caCert).clientAuth(TlsServerCredentials.ClientAuth.REQUIRE).build();
ChannelCredentials channelCreds = TlsChannelCredentials.newBuilder().trustManager(caCert).build();
Status status = expectFailedHandshake(channelCreds, serverCreds);
assertEquals(Status.Code.UNAVAILABLE, status.getCode());
StatusException sre = status.asException();
// because of netty/netty#11604 we need to check for both TLSv1.2 and v1.3 behaviors
if (sre.getCause() instanceof SSLHandshakeException) {
assertThat(sre).hasCauseThat().isInstanceOf(SSLHandshakeException.class);
assertThat(sre).hasCauseThat().hasMessageThat().contains("SSLV3_ALERT_HANDSHAKE_FAILURE");
} else {
// Client cert verification is after handshake in TLSv1.3
assertThat(sre).hasCauseThat().hasCauseThat().isInstanceOf(SSLException.class);
assertThat(sre).hasCauseThat().hasMessageThat().contains("CERTIFICATE_REQUIRED");
}
}
Aggregations