JDK-7095419 : Java 7 incompatible with java 6 in use of IP v.6
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-09-27
  • Updated: 2012-03-20
  • Resolved: 2011-09-28
Description
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows 7 Home Premium. As far as I know, no special configurations.

A DESCRIPTION OF THE PROBLEM :
In Java version 7 attempts to set up IP socket try to use IP6, even when the PC has no IP v.6 networking configured. It is necessary to run programs with the java.net.preferIPv4Stack=true switch in the command line. This was not the case with Java v.6, and there is no reference that I can find in the release notes to the change.

It appears that the default settings of the IP version parameters have been changed.

REGRESSION.  Last worked in version 6u26

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A message that the connection is OK
ACTUAL -
An error message showing an I/O exception

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testsocket;

import java.net.Socket;

/**
 *
 * @author Peter_2
 */
public class TestSocket {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            Socket s=new Socket("www.ptoye.com", 80);
            System.out.println("Connection OK");
        } catch (Exception e) {
            System.out.println("Connection fail:"+e);
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Add a line to the command line to set the java.net.preferIPv4Stack=true. But this is a mega-pain to type in (and spell right!).

Comments
EVALUATION Submitter has confirmed that it's the firewall that is blocking the connection.
2011-09-28

EVALUATION This is unlikely to be a JDK issue. Does the submitter have VPN or Firewall software enabled that may be causing this?
2011-09-27