JDK-7115226 : Windows Vista socke read hangs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7,7u5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-11-23
  • Updated: 2012-07-30
  • Resolved: 2012-07-30
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 Availabitlity Release.

To download the current JDK release, click here.
JDK 7
7-poolResolved
Related Reports
Duplicate :  
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)

FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
WiFi connection - Intel WiFi Link 1000 BGN, Driver version 14.1.1.3 (2011-05-01)

A DESCRIPTION OF THE PROBLEM :
When downloading anything from the remote URL method java.net.URL.url.openStream() followed by InputStream.read(byte[]) hangs:

"main" prio=6 tid=0x0000000001edb000 nid=0xe14 runnable [0x000000000200f000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:150)
        at java.net.SocketInputStream.read(SocketInputStream.java:121)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
        - locked <0x00000000eb31dd68> (a java.io.BufferedInputStream)
        at sun.net.www.MeteredStream.read(MeteredStream.java:134)
        - locked <0x00000000eb320b58> (a sun.net.www.http.KeepAliveStream)
        at java.io.FilterInputStream.read(FilterInputStream.java:133)
        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2968)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
        - locked <0x00000000eb2fc500> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read(FilterInputStream.java:107)
        at io.DownloadJar.main(DownloadJar.java:20)

I can provide you with Windows process dump (DMP) as well as full thread dump if needed.

What is absolutely crazy about this bug is that on Ubuntu that I run on VirtualBox on the very same machine it works 100% of the time.

I suspect a bug in Windows JVM native code.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

REGRESSION.  Last worked in version 7

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run simple program provided below under Windows 7.


EXPECTED VERSUS ACTUAL BEHAVIOR :
This program will very often hang before downloading the full contents of netty-3.2.6.Final.jar
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages - this program just hangs

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
package io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class DownloadJar {

	public static void main(String[] args) throws MalformedURLException {
		URL url = new URL("http://repo1.maven.org/maven2/org/jboss/netty/netty/3.2.6.Final/netty-3.2.6.Final.jar");
		try (BufferedInputStream in = new BufferedInputStream(url.openStream());
				BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("netty.jar"))) {
			
			byte[] buf = new byte[2048];
			int len = 0;
			int total = 0;
			while ((len = in.read(buf)) > 0) {
				total += len;
				System.out.println(total / 1024 + "KB");
				out.write(buf, 0, len);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
unknown
This bug can be reproduced under following environment:

FULL PRODUCT VERSION :
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

Unless using the -Djava.net.preferIPv4Stack=true, otherwise it hangs every time.

Another way to reproduce is to run a Tomcat unit test

1. svn co http://svn.apache.org/repos/asf/tomcat/trunk
2. cd trunk
3. [with java 6] ant
4. [with java 7]  ant -Dtest.entry=org.apache.catalina.connector.TestSendFile test-bio test-nio

Work arounds are
a) Use Java 6
b) Use -Djava.net.preferIPv4Stack=true when using Java 7

Comments
WORK AROUND -Djava.net.preferIPv4Stack=true
2012-07-16

EVALUATION This bug was not reproducible. The machine configuration used is as mentioned below: 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) FULL OS VERSION : Microsoft Windows [Version 6.1.7601] EXTRA RELEVANT SYSTEM CONFIGURATION : WiFi connection - Intel(R) Centrino(R) Advanced-N 6205, Driver Version: 14.0.1.2
2011-12-12