JDK-8087190 : Regression in sun.net.util.IPAddressUtil.isIPv4LiteralAddress(String)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8u45
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-05-26
  • Updated: 2016-08-24
  • Resolved: 2015-08-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u72Fixed 9 b80Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin teknisk-dhcp288.basefarm.no 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
After the fix for https://bugs.openjdk.java.net/browse/JDK-8040747, things like

  // just the dot separators of an IPv4 address, no digits
  isIPv4LiteralAddress("...")

will return true.  Prior to the change, even a single missing octet ( isIPv4LiteralAddress(".0.0.0") ) would return false.

REGRESSION.  Last worked in version 7u80

ADDITIONAL REGRESSION INFORMATION: 
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home scala -e 'for (a <- List("...", "0.0.0.", ".0.0.0", "0.0.0.0")) { println(a + "\t: " + sun.net.util.IPAddressUtil.isIPv4LiteralAddress(a)) }'
...	: true
0.0.0.	: true
.0.0.0	: true
0.0.0.0	: true

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
$ JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home scala -e 'for (a <- List("...", "0.0.0.", ".0.0.0", "0.0.0.0")) { println(a + "\t: " + sun.net.util.IPAddressUtil.isIPv4LiteralAddress(a)) }'
...	: false
0.0.0.	: false
.0.0.0	: false
0.0.0.0	: true

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
1. Run the attached test case (IPAddressUtilTest.java) in Linux and MAC OS(64-bit). 2. Couldn't reproduce the issue as reported by the submitter with JDK 8u45, 8u60 ea b19, 9 ea b68. 3. Output with JDK 8u45: -------------------------- $ javac IPAddressUtilTest.java IPAddressUtilTest.java:30: warning: IPAddressUtil is internal proprietary API and may be removed in a future release if (!IPAddressUtil.isIPv4LiteralAddress(addr) && ^ IPAddressUtilTest.java:31: warning: IPAddressUtil is internal proprietary API and may be removed in a future release !IPAddressUtil.isIPv6LiteralAddress(addr)) { ^ 2 warnings $ java IPAddressUtilTest Moving this up for review based upon additional input from the submitter: --------------------------------------- On 6/11/2015 12:15 PM, ...... wrote: > > > There���s already a test in OpenJDK for this method; here���s a patch that adds additional ���bad��� examples to that test: > > $ hg diff > diff -r 687fd7c7986d test/sun/net/util/IPAddressUtilTest.java > --- a/test/sun/net/util/IPAddressUtilTest.java Tue Mar 04 11:51:53 2014 -0800 > +++ b/test/sun/net/util/IPAddressUtilTest.java Thu Jun 11 08:41:51 2015 +0200 > @@ -39,6 +39,9 @@ > {"238.255.2550.255", bad}, > {"238.2550.255.255", bad}, > {"2380.255.255.255", bad}, > + {".255.255.255", bad}, > + {"255.255.255.", bad}, > + {"...", bad}, > {"10::10", good}, > {"10::10.1", bad}, > {"10::10.1.2", bad}, > > Running just this test on my machine looks like this: > > $ javac test/sun/net/util/IPAddressUtilTest.java > test/sun/net/util/IPAddressUtilTest.java:62: warning: IPAddressUtil is internal proprietary API and may be removed in a future release > if (!IPAddressUtil.isIPv4LiteralAddress(addr) && > ^ > test/sun/net/util/IPAddressUtilTest.java:63: warning: IPAddressUtil is internal proprietary API and may be removed in a future release > !IPAddressUtil.isIPv6LiteralAddress(addr)) { > ^ > 2 warnings > > $ java -cp test/sun/net/util IPAddressUtilTest > Exception in thread "main" java.lang.RuntimeException: wrong result for .255.255.255 > at IPAddressUtilTest.main(IPAddressUtilTest.java:68) > > $ java -version > java version "1.8.0_45" > Java(TM) SE Runtime Environment (build 1.8.0_45-b14) > Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) ---------------------------------------------------
11-06-2015