Skip to content

Commit 67fe528

Browse files
authored
Merge pull request #478 from songhanlin/ipv6
调整host和port分隔方式, 适应ipv6的地址
2 parents 87865d8 + bada596 commit 67fe528

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

txlcn-common/src/main/java/com/codingapi/txlcn/common/util/ApplicationInformation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public static String[] splitAddress(String hostAndPort) {
5454
if (hostAndPort.indexOf(':') == -1) {
5555
throw new IllegalStateException("non exists port");
5656
}
57-
String[] result = hostAndPort.split(":");
57+
int index = hostAndPort.lastIndexOf(":");
58+
String host = hostAndPort.substring(0, index);
59+
String port = hostAndPort.substring(index + 1);
60+
String[] result = {host, port};
5861
if (StringUtils.isEmpty(result[0])) {
5962
result[0] = "0.0.0.0";
6063
return result;

txlcn-txmsg/src/main/java/com/codingapi/txlcn/txmsg/dto/TxManagerHost.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class TxManagerHost {
4242
public static List<TxManagerHost> parserList(List<String> managerHost) {
4343
List<TxManagerHost> list = new ArrayList<>();
4444
for(String host:managerHost){
45-
String [] array = host.split(":");
46-
TxManagerHost manager = new TxManagerHost(array[0],Integer.parseInt(array[1]));
45+
int index = host.lastIndexOf(":");
46+
TxManagerHost manager = new TxManagerHost(host.substring(0, index),
47+
Integer.parseInt(host.substring(index + 1)));
4748
list.add(manager);
4849
}
4950
return list;

0 commit comments

Comments
 (0)