Skip to content

Commit

Permalink
Merge pull request #287 from alex268/master
Browse files Browse the repository at this point in the history
Fixed SDK freezing when use yc-auth-provider-shaded
  • Loading branch information
alex268 authored Jun 26, 2024
2 parents b8320fb + 8d516a3 commit cf1fef2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
8 changes: 8 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
<groupId>io.grpc</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -139,6 +143,10 @@
<groupId>io.grpc</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Expand Down
38 changes: 21 additions & 17 deletions core/src/main/java/tech/ydb/core/impl/YdbDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,28 @@ private void tick() {

private void runDiscovery() {
lastUpdateTime = handler.instant();

final GrpcTransport transport = handler.createDiscoveryTransport();
logger.debug("execute list endpoints on {} with timeout {}", transport, discoveryTimeout);
DiscoveryProtos.ListEndpointsRequest request = DiscoveryProtos.ListEndpointsRequest.newBuilder()
.setDatabase(discoveryDatabase)
.build();

GrpcRequestSettings grpcSettings = GrpcRequestSettings.newBuilder()
.withDeadline(discoveryTimeout)
.build();

transport.unaryCall(DiscoveryServiceGrpc.getListEndpointsMethod(), grpcSettings, request)
.whenComplete((res, ex) -> transport.close()) // close transport for any result
.thenApply(OperationBinder.bindSync(
DiscoveryProtos.ListEndpointsResponse::getOperation,
DiscoveryProtos.ListEndpointsResult.class
))
.whenComplete(this::handleDiscoveryResult);
try {
logger.debug("execute list endpoints on {} with timeout {}", transport, discoveryTimeout);
DiscoveryProtos.ListEndpointsRequest request = DiscoveryProtos.ListEndpointsRequest.newBuilder()
.setDatabase(discoveryDatabase)
.build();

GrpcRequestSettings grpcSettings = GrpcRequestSettings.newBuilder()
.withDeadline(discoveryTimeout)
.build();

transport.unaryCall(DiscoveryServiceGrpc.getListEndpointsMethod(), grpcSettings, request)
.whenComplete((res, ex) -> transport.close()) // close transport for any result
.thenApply(OperationBinder.bindSync(
DiscoveryProtos.ListEndpointsResponse::getOperation,
DiscoveryProtos.ListEndpointsResult.class
))
.whenComplete(this::handleDiscoveryResult);
} catch (Throwable th) {
transport.close();
handleDiscoveryResult(null, th);
}
}

private void handleThrowable(Throwable th) {
Expand Down

0 comments on commit cf1fef2

Please sign in to comment.