Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4323621

register/export action in Activatable constructors should be atomic

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.3.0
    • core-libs
    • beta
    • sparc
    • solaris_2.5



      Name: acR10002 Date: 03/21/2000


      In some cases, RMI daemon doesn't correctly restore the state from it's logs after
      crashing or shutdown. Depending on the port value, restarting of rmid can
      produce two different exceptions inside it. The following test code allows to
      reproduce these exceptions :

      -------------------- ActivatableImpl.java ------------------

      import java.rmi.activation.*;
      import java.rmi.MarshalledObject;
      import java.rmi.RemoteException;
      import java.rmi.Remote;

      public class ActivatableImpl extends Activatable implements Remote {
          
          public ActivatableImpl(String location, MarshalledObject data,
                                 boolean restart, int port)
            throws ActivationException, RemoteException {
              super(location, data, restart, port);
          }
      }

      ------------------------------------------------------------

      --------------------------- Test.java ----------------------

      import java.rmi.activation.*;
      import java.rmi.MarshalledObject;
      import java.rmi.RemoteException;

      public class Test {

          public static void main(String args[]) {
              try {
                  // Create activation group descriptor with no overrides to Java environment
                  // and default environment to pass to child VM
                  ActivationGroupDesc groupDesc = new ActivationGroupDesc(null, null);
                  // Get activation system for current VM
                  ActivationSystem system = ActivationGroup.getSystem();
                  // Register group
                  ActivationGroupID groupID = system.registerGroup(groupDesc);
                  // Create activation group for current VM
                  ActivationGroup.createGroup(groupID, groupDesc, 0);
              } catch(Exception e) {
                  e.printStackTrace(System.out);
                  exit("An Exception occurred while creating the default Activation Group. Please make sure that
      RMID is running: " + e.getMessage(), 1);
              }
              
              try {
                  // Register and export activatable object on a negative port
                  Activatable obj = new ActivatableImpl("http://merlin", null, true, -1);
              } catch (IllegalArgumentException e) {
                  exit("Test OK: got IllegalArgumentException, as expected : "+ e, 1);
              } catch (Exception e1) {
                  e1.printStackTrace(System.out);
                  exit("Test FAIL : got unexpected Exception : " + e1, 1);
              }
              exit("Test FAILED : object was exported on a negative port", 0);
          }

          private static void exit(String message, int code) {
              System.out.println(message);
              System.exit(code);
          }
      }



      ------------------------------------------------------------

      The following steps are needed to reproduce this bug :

      ------------------------------------------------------------
      % javac Test.java ActivatableImpl.java
      % rmic ActivatableImpl
      % rmiregistry &
      [6] 14326
      ------------------------------------------------------------

      The first problem arises then restarting rmid on the same port as
      it was started before :

      ------------------------------------------------------------
      % rmid &
      [7] 14342
      % java Test
      Test OK: got IllegalArgumentException, as expected : java.lang.IllegalArgumentException: Port value out of
      range: -1
      % rmid -stop
      % activation daemon shut down
      [7]+ Done rmid
      % rmid

      rmid: unable to restart service
      rmid: exception occurred: group creation failed after 2 tries; nested exception is:
              java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
              java.io.EOFException
      java.rmi.activation.ActivationException: group creation failed after 2 tries; nested exception is:
              java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
              java.io.EOFException
      java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
              java.io.EOFException
      java.io.EOFException
              at java.io.DataInputStream.readByte(DataInputStream.java:224)
              at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:186)
              at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
              at java.rmi.activation.ActivationGroup_Stub.newInstance(Unknown Source)
              at sun.rmi.server.Activation$ObjectEntry.activate(Activation.java:1441)
              at sun.rmi.server.Activation$GroupEntry.activate(Activation.java:1094)
              at sun.rmi.server.Activation$GroupEntry.restartServices(Activation.java:836)
              at sun.rmi.server.Activation.restartServices(Activation.java:184)
              at sun.rmi.server.Activation.startActivation(Activation.java:146)
              at sun.rmi.server.Activation.main(Activation.java:1977)

      ------------------------------------------------------------

      Second problem arises then restarting rmid on a different port :

      ------------------------------------------------------------
      % rm -rf log
      % rmid &
      [7] 14502
      % java Test
      Test OK: got IllegalArgumentException, as expected : java.lang.IllegalArgumentException: Port value out of
      range: -1
      % rmid -stop
      % activation daemon shut down
      [7]+ Done rmid
      % rmid -port 50000
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err:Exception in starting ActivationGroupInit:
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err:java.rmi.activation.ActivationException: exception creating
      group; nested exception is:
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: java.rmi.ConnectException: Connection refused to host:
      192.168.205.170; nested exception is:
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: java.net.ConnectException: Connection refused
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err:java.rmi.ConnectException: Connection refused to host:
      192.168.205.170; nested exception is:
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: java.net.ConnectException: Connection refused
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err:java.net.ConnectException: Connection refused
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at java.net.PlainSocketImpl.socketConnect(Native
      Method)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at java.net.Socket.<init>(Socket.java:273)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at java.net.Socket.<init>(Socket.java:100)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:25)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:120)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
      Tue Mar 21 18:03:34 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)
      Tue Mar 21 18:03:35 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.server.Activation$ActivationSystemImpl_Stub.activeGroup(Unknown Source)
      Tue Mar 21 18:03:35 GMT+03:00 2000:ExecGroup-0:err: at
      java.rmi.activation.ActivationGroup.createGroup(ActivationGroup.java:332)
      Tue Mar 21 18:03:35 GMT+03:00 2000:ExecGroup-0:err: at
      sun.rmi.server.ActivationGroupInit.main(ActivationGroupInit.java:54)

      rmid: unable to restart service
      rmid: exception occurred: timeout creating child process
      java.rmi.activation.ActivationException: timeout creating child process
              at sun.rmi.server.Activation$GroupEntry.getInstantiator(Activation.java:1221)
       at sun.rmi.server.Activation$GroupEntry.activate(Activation.java:1088)
              at sun.rmi.server.Activation$GroupEntry.restartServices(Activation.java:836)
              at sun.rmi.server.Activation.restartServices(Activation.java:184)
              at sun.rmi.server.Activation.startActivation(Activation.java:146)
              at sun.rmi.server.Activation.main(Activation.java:1977)

      ------------------------------------------------------------

      This output doesn't depend on the means of restarting rmid, either it was killed
      or correctly shutdowned.

      ======================================================================

            awollratsunw Ann Wollrath (Inactive)
            aycsunw Ayc Ayc (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: