Skip to content

Commit

Permalink
Fix Java SDK URI parsing. (#882)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
  • Loading branch information
artursouza authored Jun 22, 2023
1 parent 201dbc5 commit 76aec01
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sdk/src/main/java/io/dapr/client/DaprClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,20 @@ private DaprClient buildDaprClientGrpc() {
}

private ManagedChannel buildGrpcManagedChanel() {
String host = Properties.SIDECAR_IP.get();
String address = Properties.SIDECAR_IP.get();
int port = Properties.GRPC_PORT.get();
boolean insecure = true;
String grpcEndpoint = Properties.GRPC_ENDPOINT.get();
if ((grpcEndpoint != null) && !grpcEndpoint.isEmpty()) {
URI uri = URI.create(grpcEndpoint);
insecure = uri.getScheme().equalsIgnoreCase("http");
port = uri.getPort() > 0 ? uri.getPort() : (insecure ? 80 : 443);
address = uri.getHost();
if ((uri.getPath() != null) && !uri.getPath().isEmpty()) {
address += uri.getPath();
}
}
ManagedChannelBuilder builder = ManagedChannelBuilder.forAddress(host, port)
ManagedChannelBuilder builder = ManagedChannelBuilder.forAddress(address, port)
.userAgent(Version.getSdkVersion());
if (insecure) {
builder = builder.usePlaintext();
Expand Down

0 comments on commit 76aec01

Please sign in to comment.