Skip to content

Commit faaa55b

Browse files
DeviceInfracopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 875062474
1 parent 0fa12a9 commit faaa55b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/java/com/google/devtools/mobileharness/shared/util/comm/stub/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ java_library(
6969
runtime_deps = [
7070
],
7171
deps = [
72+
":grpc_address_util",
7273
"//src/java/com/google/devtools/mobileharness/shared/constant/closeable",
7374
"@grpc-java//core",
7475
"@grpc-java//stub",
@@ -128,3 +129,8 @@ java_library(
128129
"@maven//:javax_inject_jsr330_api",
129130
],
130131
)
132+
133+
java_library(
134+
name = "grpc_address_util",
135+
srcs = ["GrpcAddressUtil.java"],
136+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.devtools.mobileharness.shared.util.comm.stub;
18+
19+
/** Utility class for gRPC addresses. */
20+
public final class GrpcAddressUtil {
21+
22+
private GrpcAddressUtil() {}
23+
24+
public static String getGrpcTarget(String address) {
25+
if (address.startsWith("dns:///")) {
26+
return address;
27+
}
28+
return "dns:///" + address;
29+
}
30+
31+
public static String getGrpcAuthority(String address) {
32+
if (address.startsWith("dns:///")) {
33+
return address.substring("dns:///".length());
34+
}
35+
return address;
36+
}
37+
}

0 commit comments

Comments
 (0)