提交 d7c11aab authored 作者: Thomas Mueller's avatar Thomas Mueller

java.net.preferIPv6Addresses=true test

上级 f8f4199d
...@@ -8,6 +8,7 @@ package org.h2.util; ...@@ -8,6 +8,7 @@ package org.h2.util;
import java.io.IOException; import java.io.IOException;
import java.net.BindException; import java.net.BindException;
import java.net.Inet6Address;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
...@@ -47,7 +48,24 @@ public class NetUtils { ...@@ -47,7 +48,24 @@ public class NetUtils {
if (address == null) { if (address == null) {
address = InetAddress.getLocalHost(); address = InetAddress.getLocalHost();
} }
return createSocket(address.getHostAddress(), port, ssl); return createSocket(getHostAddress(address), port, ssl);
}
/**
* Get the host address. This method adds '[' and ']' if required for
* Inet6Address that contain a ':'.
*
* @param address the address
* @return the host address
*/
public static String getHostAddress(InetAddress address) {
String host = address.getHostAddress();
if (address instanceof Inet6Address) {
if (host.indexOf(':') >= 0 && !host.startsWith("[")) {
host = "[" + host + "]";
}
}
return host;
} }
/** /**
...@@ -210,7 +228,7 @@ public class NetUtils { ...@@ -210,7 +228,7 @@ public class NetUtils {
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
// ignore // ignore
} }
String address = bind == null ? "localhost" : bind.getHostAddress(); String address = bind == null ? "localhost" : getHostAddress(bind);
if (address.equals("127.0.0.1")) { if (address.equals("127.0.0.1")) {
address = "localhost"; address = "localhost";
} }
......
...@@ -293,9 +293,7 @@ java org.h2.test.TestAll timer ...@@ -293,9 +293,7 @@ java org.h2.test.TestAll timer
/* /*
shell tool: document encoding problem. test what is wrong with -Djava.net.preferIPv6Addresses=true
mac: java -Dfile.encoding=UTF-8
windows:
download checksums (auto-verify every day) download checksums (auto-verify every day)
......
...@@ -590,4 +590,4 @@ overall httpdocs tigris eclemma separates underscore yajsw she her truncating ...@@ -590,4 +590,4 @@ overall httpdocs tigris eclemma separates underscore yajsw she her truncating
relocating smtps smtp osde joist catching guesses delimiters shortlist sheet relocating smtps smtp osde joist catching guesses delimiters shortlist sheet
rowspan cheat partitioning datepart dreamsource toussi locates fred rowspan cheat partitioning datepart dreamsource toussi locates fred
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
ops jopr googlegroups fletcher ops jopr googlegroups fletcher prefer djava
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论