|
Quick Lists
|
|
Bug ID:
|
6774170
|
|
Votes
|
0
|
|
Synopsis
|
LocalRMIServerSocketFactory should protect against ServerSocket.accept().getInetAddress() being null
|
|
Category
|
java:classes_management
|
|
Reported Against
|
|
|
Release Fixed
|
6u12(b02),
6-open(b14) (Bug ID:2169899)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
6774166
|
|
Submit Date
|
20-NOV-2008
|
|
Description
|
Using Netbeans 6.5rc2 for Java EE, with GlassFish ur2v2, in which petstore is deployed.
While pointing jvisualvm to the local GlassFish process (local attach) - I could sometimes see an exception in GlassFish log file.
When running glassfish on 6u12 - I could see an NullPointerException in the glassfish log file - and jvisualvm was not able to display GlassFish threads (thread information are obtained through JMX)
The problem occurs intermitently, and prevents jvisualvm to connect to the target application server using the attach API.
The root cause of the problem seems to be that sometime, for some reason,
the Socket created on the server (glassfish) side to handle incomminng
JMX RMI connections has a null remote InetAddress:
RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=53246] throws
java.lang.NullPointerException
at xxxxx .management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:40)
at xxxxx .rmi.transport. customer .TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:369)
at xxxxx .rmi.transport. customer .TCPTransport$AcceptLoop.run(TCPTransport.java:341)
at java.lang.Thread.run(Thread.java:619)
In the LocalRMIServerSocketFactory the remoteAddr variable returned by the forelast
line in the code snippet below is null:
public ServerSocket createServerSocket(int port)
throws IOException {
return new ServerSocket(port) {
@Override
public Socket accept() throws IOException {
Socket socket = super.accept();
InetAddress remoteAddr = socket.getInetAddress();
if (remoteAddr.isAnyLocalAddress()) {
This problem occurred several times - but not always. If you restart the glassfish appserver it may go away - or remain.
It looks as if the socket returned by accept() is not always fully initialized?
Note: the code of the LocalRMIServerSocketFactory changed between 6u11 and 6u12.
On 6u11 you get an IOException instead - saying that the remoteAddr is not a local address. It is difficult to assert that this happens because the remoteAddr is null, but I suspect as much, so this problem (ServerSocket.accept().getInetAddress()=null)
is probably older.
LocalRMIServerSocketFactory should give a better diagnostic and throw an IOException when this happens, rather than a NullPointerException.
There's still the (unlikely) possibilty that the just accepted socket has already
been closed - and in that case the exception should probably say so. Also LocalRMIServerSocketFactory should call isLoopbackAddress() rather than isAnyLocalAddress().
Posted Date : 2008-11-20 12:35:30.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
The NullPointerException is caused by 6774166.
6774166 is a spurious bug that only shows up from time to time.
However, throwing NPE is bad, because it delays the time at which the
accepted socket is closed by the server (the accepted socket is closed
when it is eventually gc'ed).
During all this time, the client waits for the server to respond - and
may also retry the connection.
Working around 6774166 and cleanly closing the accepted socket right away
when getInetAddress() returns null is much better for client performance.
Posted Date : 2008-11-20 18:09:15.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |