United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4856776 : RMI call remains blocked even after network cable is unplugged in Solaris 8

Details
Type:
Bug
Submit Date:
2003-05-01
Status:
Closed
Updated Date:
2004-02-05
Project Name:
JDK
Resolved Date:
2004-12-10
Component:
other-libs
OS:
solaris_8
Sub-Component:
corba:orb
CPU:
sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:
1.4.1 (05)

Related Reports
Backport:

Sub Tasks

Description
When using the simple Helloworld Testcase given as part of the "Getting Started with RMI-IIOP" we unplug the network cable which connects client and server, and wait. Since the cable is unplugged, the RMI call remains blocked forever (we have tested up to 15 minutes). RMI should have thrown an exception at some point here, but it didn't actually throw an exception until the connection was plugged back in. At that point, a Marshal exception was thrown. This behaviour is seen on SOlaris 8 and 9 systems. Surpisingly, on the Windows platform (win2K), the RMI client immeidately gives an exception when the client network cable is plugged out.

                                    

Comments
EVALUATION

There is a workaround in MessageBase.readFully for an old networking bug that 
has since been fixed. 
Looks like Bug Id 4178050.

Remove the retries to InputStream.read()

###@###.### 2003-05-28
-----------------------------------------

1.4.1_04 is a security release. This fix has been pushed to 1.4.1_05

###@###.### 2003-06-27
                                     
2003-05-28
SUGGESTED FIX

--- MessageBase.java    Mon May 12 05:50:14 2003

*** 512,536 ****
      public static void readFully(java.io.InputStream is, byte[] buf,
              int offset, int size) throws IOException {
          int n = 0;
          while (n < size) {
              int bytecount=0;
-             int itns=0;
  
-             // The while loop here is to workaround a possible bug
-             // in the Solaris JVM where an "interrupted system call"
-             // error is thrown as a SocketException instead of being
-             // retried inside SocketInputStream.read().
-             while ( true ) {
-                 try {
                      bytecount = is.read(buf, offset + n, size - n);
-                 break;
-                 } catch ( java.io.IOException ex ) {
-                 if ( itns++ >= 5 )
-                 throw ex;
-                 }
-             }
  
              if (bytecount < 0)
              throw new IOException();
              n += bytecount;
          }
--- 512,523 ----

###@###.### 2003-05-29
                                     
2003-05-29
WORK AROUND

Extend DefaultSocketFactory and override createSocket and setSoTimeout.
Set -Dcom.sun.CORBA.connection.ORBSocketFactoryClass=OwnSocketFactory

Without the changes mentioned in the evaluation section the timeout will appear
to be 5 times longer that the SoTimeout.

###@###.### 2003-05-28

The problem with the timeout appearing 5 times longer than what is set will be fixed with JDK 1.4.1_04

Here is the source file which sets the time out:

************************************************************

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

import org.omg.CORBA.ORB;
import org.omg.CORBA.COMM_FAILURE;
import org.omg.CORBA.CompletionStatus;

import com.sun.corba.se.connection.EndPointInfo;
import com.sun.corba.se.connection.GetEndPointInfoAgainException;
import com.sun.corba.se.connection.ORBSocketFactory;
import com.sun.corba.se.internal.core.IOR;
import com.sun.corba.se.internal.iiop.EndPointImpl;
import com.sun.corba.se.internal.ior.IIOPProfileTemplate ;
import com.sun.corba.se.internal.ior.IIOPAddress ;
import com.sun.corba.se.internal.orbutil.MinorCodes;

public class OwnSocketFactory 
    implements 
        ORBSocketFactory
{
    public OwnSocketFactory()
    {
    }

    public ServerSocket createServerSocket(String type, int port) throws
            IOException
    {
            if (! type.equals(ORBSocketFactory.IIOP_CLEAR_TEXT)) {
                 throw new COMM_FAILURE(
                "DefaultSocketFactory.createServerSocket only handles " +
                    "IIOP_CLEAR_TEXT, given: " + type,
                    MinorCodes.DEFAULT_CREATE_SERVER_SOCKET_GIVEN_NON_IIOP_CLEAR_TEST,
                    CompletionStatus.COMPLETED_NO);
            }
                                   
        ServerSocket sc = new ServerSocket(port);
            return sc;
    }

    public EndPointInfo getEndPointInfo(ORB orb,
                                        IOR ior,
                                        EndPointInfo endPointInfo)
    {
        IIOPProfileTemplate temp = ior.getProfile().getTemplate() ;
            IIOPAddress primary = temp.getPrimaryAddress() ;

            return new EndPointImpl(ORBSocketFactory.IIOP_CLEAR_TEXT,
                                primary.getPort(),
                                primary.getHost().toLowerCase());
    }

    public Socket createSocket(EndPointInfo endPointInfo) throws
            IOException,
            GetEndPointInfoAgainException
    {
        Socket sc = new Socket(endPointInfo.getHost(), endPointInfo.getPort());
        try {
            sc.setSoTimeout(30000);  // <<---- set the timeout for the socket  
                                    // Here set to 30 seconds
        } catch (Exception e) {
            System.err.println(e);
        }
        
            return sc;
    }
}

###@###.### 2003-06-06
                                     
2003-06-06
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.1_05
1.4.2_04

FIXED IN:
1.4.1_05
1.4.2_04

INTEGRATED IN:
1.4.1_05
1.4.2_04

VERIFIED IN:
1.4.1_05
1.4.2_04


                                     
2004-06-14



Hardware and Software, Engineered to Work Together