aboutsummaryrefslogtreecommitdiff
path: root/other/java/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'other/java/client/src')
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java2
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
index 6c57e2e0d..56aa35876 100644
--- a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
+++ b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
@@ -54,7 +54,7 @@ public class FilerGrpcClient {
.negotiationType(NegotiationType.TLS)
.sslContext(sslContext));
- filerAddress = String.format("%s:%d", host, grpcPort - 10000);
+ filerAddress = SeaweedUtil.joinHostPort(host, grpcPort - 10000);
FilerProto.GetFilerConfigurationResponse filerConfigurationResponse =
this.getBlockingStub().getFilerConfiguration(
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
index 66ea9a98d..027e49b96 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
@@ -43,4 +43,14 @@ public class SeaweedUtil {
String name = fullpath.substring(sep + 1);
return new String[]{parent, name};
}
+
+ public static String joinHostPort(String host, int port) {
+ if (host.startsWith("[") && host.endsWith("]")) {
+ return host + ":" + port;
+ }
+ if (host.indexOf(':')>=0) {
+ return "[" + host + "]:" + port;
+ }
+ return host + ":" + port;
+ }
}