Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jdk17u
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
einsteinathome
openjdk
jdk17u
Commits
c969db1c
Commit
c969db1c
authored
Dec 8, 2016
by
Felix Yang
Browse files
Options
Downloads
Patches
Plain Diff
8169115: java/net/InetAddress/ptr/lookup.sh failed intermittently
Reviewed-by: dsamersoff
parent
d0feb351
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
jdk/test/java/net/InetAddress/ptr/Lookup.java
+62
-18
62 additions, 18 deletions
jdk/test/java/net/InetAddress/ptr/Lookup.java
jdk/test/java/net/InetAddress/ptr/lookup.sh
+0
-72
0 additions, 72 deletions
jdk/test/java/net/InetAddress/ptr/lookup.sh
with
62 additions
and
90 deletions
jdk/test/java/net/InetAddress/ptr/Lookup.java
+
62
−
18
View file @
c969db1c
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2016,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -22,35 +22,79 @@
*/
/*
* Lookup/reverse lookup class for regression test 4773521
* @test
* @bug 4773521
* @summary Test that reverse lookups of IPv4 addresses work when IPv6
* is enabled
* @library /test/lib
* @build jdk.test.lib.JDKToolFinder
* jdk.test.lib.process.OutputAnalyzer
* Lookup
* @run main Lookup root
*
*
* Lookup/reverse lookup class for regression test 4773521 - see
* lookup.sh for details.
*/
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.List
;
public
class
Lookup
{
public
static
void
main
(
String
args
[])
throws
UnknownHostException
{
import
jdk.test.lib.JDKToolFinder
;
import
jdk.test.lib.process.OutputAnalyzer
;
// reverse lookup
public
class
Lookup
{
private
static
final
String
HOST
=
"icann.org"
;
private
static
final
String
SKIP
=
"SKIP"
;
private
static
final
String
CLASS_PATH
=
System
.
getProperty
(
"test.class.path"
);
if
(
args
[
0
].
equals
(
"-q=PTR"
))
{
InetAddress
ia
=
InetAddress
.
getByName
(
args
[
1
]);
System
.
out
.
println
(
ia
.
getHostName
());
public
static
void
main
(
String
args
[])
throws
IOException
{
String
addr
=
null
;
String
ipv4Name
=
null
;
if
(
args
.
length
==
0
)
{
// First check that host resolves to IPv4 address
try
{
InetAddress
ia
=
InetAddress
.
getByName
(
HOST
);
addr
=
ia
.
getHostAddress
();
}
catch
(
UnknownHostException
e
)
{
System
.
out
.
print
(
SKIP
);
return
;
}
}
else
{
String
tmp
=
lookupWithIPv4Prefer
();
System
.
out
.
println
(
"IPv4 lookup results: ["
+
tmp
+
"]"
);
if
(
SKIP
.
equals
(
tmp
))
{
System
.
out
.
println
(
HOST
+
" can't be resolved - test skipped."
);
return
;
}
// lookup address
String
[]
strs
=
tmp
.
split
(
":"
);
addr
=
strs
[
0
];
ipv4Name
=
strs
[
1
];
}
String
addr
;
if
(
args
[
0
].
equals
(
"-q=A"
))
{
addr
=
args
[
1
];
// reverse lookup
InetAddress
ia
=
InetAddress
.
getByName
(
addr
);
String
name
=
ia
.
getHostName
();
if
(
args
.
length
==
0
)
{
System
.
out
.
print
(
addr
+
":"
+
name
);
return
;
}
else
{
addr
=
args
[
0
];
System
.
out
.
println
(
"(default) "
+
addr
+
"--> "
+
name
);
if
(!
ipv4Name
.
equals
(
name
))
{
throw
new
RuntimeException
(
"Mismatch between default"
+
" and java.net.preferIPv4Stack=true results"
);
}
}
InetAddress
ia
=
InetAddress
.
getByName
(
args
[
1
]);
System
.
out
.
println
(
ia
.
getHostAddress
());
}
static
String
lookupWithIPv4Prefer
()
throws
IOException
{
String
java
=
JDKToolFinder
.
getTestJDKTool
(
"java"
);
String
testClz
=
Lookup
.
class
.
getName
();
List
<
String
>
cmd
=
List
.
of
(
java
,
"-Djava.net.preferIPv4Stack=true"
,
"-cp"
,
CLASS_PATH
,
testClz
);
System
.
out
.
println
(
"Executing: "
+
cmd
);
return
new
OutputAnalyzer
(
new
ProcessBuilder
(
cmd
).
start
()).
getOutput
();
}
}
This diff is collapsed.
Click to expand it.
jdk/test/java/net/InetAddress/ptr/lookup.sh
deleted
100644 → 0
+
0
−
72
View file @
d0feb351
#!/bin/sh
#
# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4773521
# @build Lookup
# @run shell lookup.sh
# @summary Test that reverse lookups of IPv4 addresses work when IPv6
# is enabled.
# The host that we try to resolve
HOST
=
javaweb.sfbay.sun.com
CLASSPATH
=
${
TESTCLASSES
}
export
CLASSPATH
JAVA
=
"
${
TESTJAVA
}
/bin/java"
# First check that host resolves to IPv4 address.
echo
''
ADDR
=
`
$JAVA
-Djava
.net.preferIPv4Stack
=
true
Lookup
-q
=
A
$HOST
`
if
[
$?
!=
0
]
;
then
echo
"
$HOST
can't be resolved - test skipped."
exit
0
fi
echo
"
$HOST
-->
$ADDR
"
# IPv4 reverse lookup
echo
''
OUT1
=
`
$JAVA
${
TESTVMOPTS
}
-Djava
.net.preferIPv4Stack
=
true
Lookup
-q
=
PTR
$ADDR
`
echo
"(IPv4)
$ADDR
-->
$OUT1
"
# reverse lookup (default)
echo
''
OUT2
=
`
$JAVA
${
TESTVMOPTS
}
Lookup
-q
=
PTR
$ADDR
`
echo
"(default)
$ADDR
-->
$OUT2
"
# Compare results
if
[
"
$OUT1
"
!=
"
$OUT2
"
]
;
then
echo
''
echo
"Mistmatch between default and java.net.preferIPv4Stack=true results"
exit
1
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment