-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
7
-
x86
-
windows_2008
FULL PRODUCT VERSION :
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Server 2008 R2 Standard Service Pack 1
A DESCRIPTION OF THE PROBLEM :
When process E has bound a socket to a given port,
an BindException is expected in process J (=java 7 VM) when trying to bind to the same port.
Cases conforming with expectations (receiving the BindException)
E is also a Java 7 VM
Cases NOT conforming with expectations (receiving the BindException)
E is a Java 6 VM or E is a C++ based program, using winsock2 calls
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. jre6\bin\java -jar TestBinding.jar 8500
2. jre7\\bin\java -jar TestBinding.jar 8500
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at com.barco.bg.core.server.test.TestBinding.main(TestBinding.java:35)
ACTUAL -
Bind on port 8500 succeeded.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* ---------------------------------------------------------------------------
* File : TestBinding.java
* Created : Nov 2011
*
* History
*/
//package com.barco.bg.core.server.test;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
*/
class TestBinding
{
/**
*/
public static void main (String[] args)
{
int port = Integer.parseInt (args [0]);
ServerSocketChannel srvSock;
try
{
byte[] msg = "TestBinding(J)".getBytes ("UTF-8");
System.out.println ("Binding on port " + port);
srvSock = ServerSocketChannel.open ();
srvSock.socket ().bind (new InetSocketAddress (port), 10);
System.out.println ("Bind on port " + port + " succeeded.");
while (true)
{
SocketChannel sc = srvSock.accept ();
if (sc != null)
{
Socket s = sc.socket ();
s.getOutputStream ().write (msg);
s.getOutputStream ().flush ( );
s.close ();
}
else
System.out.println ("accept returned null.");
}
}
catch (Throwable e)
{
e.printStackTrace ();
}
} // main
} // class TestBinding
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workaround: stick with java 6 VM.
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Server 2008 R2 Standard Service Pack 1
A DESCRIPTION OF THE PROBLEM :
When process E has bound a socket to a given port,
an BindException is expected in process J (=java 7 VM) when trying to bind to the same port.
Cases conforming with expectations (receiving the BindException)
E is also a Java 7 VM
Cases NOT conforming with expectations (receiving the BindException)
E is a Java 6 VM or E is a C++ based program, using winsock2 calls
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. jre6\bin\java -jar TestBinding.jar 8500
2. jre7\\bin\java -jar TestBinding.jar 8500
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at com.barco.bg.core.server.test.TestBinding.main(TestBinding.java:35)
ACTUAL -
Bind on port 8500 succeeded.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* ---------------------------------------------------------------------------
* File : TestBinding.java
* Created : Nov 2011
*
* History
*/
//package com.barco.bg.core.server.test;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
*/
class TestBinding
{
/**
*/
public static void main (String[] args)
{
int port = Integer.parseInt (args [0]);
ServerSocketChannel srvSock;
try
{
byte[] msg = "TestBinding(J)".getBytes ("UTF-8");
System.out.println ("Binding on port " + port);
srvSock = ServerSocketChannel.open ();
srvSock.socket ().bind (new InetSocketAddress (port), 10);
System.out.println ("Bind on port " + port + " succeeded.");
while (true)
{
SocketChannel sc = srvSock.accept ();
if (sc != null)
{
Socket s = sc.socket ();
s.getOutputStream ().write (msg);
s.getOutputStream ().flush ( );
s.close ();
}
else
System.out.println ("accept returned null.");
}
}
catch (Throwable e)
{
e.printStackTrace ();
}
} // main
} // class TestBinding
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workaround: stick with java 6 VM.
- duplicates
-
JDK-7179799 No BindException when another program is using the port
-
- Closed
-