← Back to team overview

openjdk team mailing list archive

Bug#573742: openjdk-6-jre: cannot open socket to localhost

 

Package: openjdk-6-jre
Version: 6b18~pre2-1
Severity: important

Latest update breaks the ability to open a socket to 127.0.0.1, unless
-Djava.net.preferIPv4Stack=true is set. Test code attached, which assumes there
is a service listening on port 80.

also, screwing with net.ipv6.bindv6only (as per #560056) has no effect

$ java network_test 
Opening Socket from 31000 to 80
Unexpected exception opening backend socket: java.net.SocketException: Invalid argument or cannot assign requested address
java.net.SocketException: Invalid argument or cannot assign requested address
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
	at java.net.Socket.connect(Socket.java:542)
	at java.net.Socket.connect(Socket.java:492)
	at java.net.Socket.<init>(Socket.java:389)
	at java.net.Socket.<init>(Socket.java:290)
	at network_test.main(test.java:19)
null

$ java -Djava.net.preferIPv4Stack=true network_test 
Opening Socket from 31000 to 80
Opened Socket from 31000 to 80
Socket[addr=/127.0.0.1,port=80,localport=31000]


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages openjdk-6-jre depends on:
ii  dpkg                    1.15.5.6         Debian package management system
ii  libaccess-bridge-java-j 1.26.2-4         Java Access Bridge for GNOME (jni 
ii  libasound2              1.0.22-2         shared library for ALSA applicatio
ii  libc6                   2.10.2-6         Embedded GNU C Library: Shared lib
ii  libgif4                 4.1.6-9          library for GIF images (library)
ii  libjpeg62               6b-16.1          The Independent JPEG Group's JPEG 
ii  libpng12-0              1.2.43-1         PNG library - runtime
ii  libpulse0               0.9.21-1         PulseAudio client libraries
ii  libx11-6                2:1.3.3-1        X11 client-side library
ii  libxext6                2:1.1.1-2        X11 miscellaneous extension librar
ii  libxi6                  2:1.3-3          X11 Input extension library
ii  libxrender1             1:0.9.5-1        X Rendering Extension client libra
ii  libxtst6                2:1.1.0-2        X11 Testing -- Resource extension 
ii  openjdk-6-jre-headless  6b18~pre2-1      OpenJDK Java runtime, using Hotspo
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

openjdk-6-jre recommends no packages.

Versions of packages openjdk-6-jre suggests:
ii  icedtea6-plugin              6b18~pre2-1 web browser plugin based on OpenJD

-- no debconf information
import java.io.*;
import java.net.*;
import java.util.*;

class network_test {

public static void main(String [] args) {

	Socket m_socket = null;
	InetAddress iNetAddress = null;
	try { iNetAddress = InetAddress.getByName("127.0.0.1"); }
	catch ( UnknownHostException e ) { System.err.println( "Unable to resolve localhost name: " + e ); return; }
	
	int tryPort = 31000;
	int m_port = 80;

	try {
		System.err.println( "Opening Socket from " + tryPort + " to " + m_port );
		m_socket = new Socket( iNetAddress, m_port, iNetAddress, tryPort );
		System.err.println( "Opened Socket from " + tryPort + " to " + m_port );
	} catch ( IOException e ) {
		System.err.println( "Unexpected exception opening backend socket: " + e );
		e.printStackTrace(System.err);
	}

	System.out.println(m_socket);
}

}

Follow ups