On Tue, 4 Mar 2025 03:02:45 GMT, SendaoYan <s...@openjdk.org> wrote:

>> Hi all,
>> 
>> Two java/net/InetAddress tests fails "java.net.UnknownHostException" on some 
>> special machines. The machine cannot connect to the Internet directly and 
>> needs to be connected to the Internet through a jump machine. The 
>> java/net/InetAddress tests report "java.net.UnknownHostException: 
>> bugs.openjdk.org: Temporary failure in name resolution" failure do not 
>> caused by JVM bug but environmentalk issue, so this PR match the 
>> java.net.UnknownHostException and throw jtreg.SkippedException instead of 
>> report test fails.
>> 
>> And run the tests with JVM options `-Dhttp.proxyHost=192.168.50.1 
>> -Dhttp.proxyPort=10991 -Dhttps.proxyHost=192.168.50.1 
>> -Dhttps.proxyPort=10991 -DsocksProxyHost=192.168.50.1 
>> -DsocksProxyPort=10991` can not work around. So I create this PR to fix the 
>> test bug.
>> 
>> Command wget shows that the machine should connect to internet through a 
>> jumper machine(192.168.50.1:10991):
>> 
>>> wget www.bing.com
>> --2025-02-24 17:56:25--  http://www.bing.com/
>> Connecting to 192.168.50.1:10991... connected.
>> Proxy request sent, awaiting response... 301 Moved Permanently
>> Location: http://cn.bing.com/ [following]
>> --2025-02-24 17:56:25--  http://cn.bing.com/
>> Reusing existing connection to 192.168.50.1:10991.
>> Proxy request sent, awaiting response... 200 OK
>> Length: 13006 (13K) [text/html]
>> Saving to: ‘index.html’
>> 
>> 
>> Change has been verified locally, test-fix only and make tests more 
>> robustness, no risk.
>
> SendaoYan has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove unnecessary Exeception

test/jdk/java/net/InetAddress/IsReachableViaLoopbackTest.java line 43:

> 41:         try {
> 42:             InetAddress addr = InetAddress.getLoopbackAddress();
> 43:             InetAddress remoteAddr = 
> InetAddress.getByAddress("bugs.openjdk.org".getBytes());

You need to pass a real address here - that is, either byte[4] for an IPv4 
address, or byte[16] for an IPv6 address.
For instance - `InetAddress.getByAddress(new byte[] { 104, 77, 118, 65 });`, or 
even `InetAddress.getByName("104.77.118.65");`
With that you should be able to remove the `catch (UnknownHostException)`

test/jdk/java/net/InetAddress/getOriginalHostName.java line 46:

> 44:         ia = getInetAddress(HOST);
> 45:         if (ia != null) testInetAddress(ia, HOST);
> 46:         ia = getInetAddress("255.255.255.0");

Please revert the changes on this line. UnknownHostException should not be 
thrown here.

test/jdk/java/net/InetAddress/getOriginalHostName.java line 47:

> 45:         if (ia != null) testInetAddress(ia, HOST);
> 46:         ia = getInetAddress("255.255.255.0");
> 47:         if (ia != null) testInetAddress(ia, null);

No need to test for `null` here (at line 47).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23767#discussion_r1979157878
PR Review Comment: https://git.openjdk.org/jdk/pull/23767#discussion_r1979160706
PR Review Comment: https://git.openjdk.org/jdk/pull/23767#discussion_r1979162058

Reply via email to