Merge jdk7-b123

Mon, 20 Dec 2010 17:18:56 -0800

author
lana
date
Mon, 20 Dec 2010 17:18:56 -0800
changeset 238
a230c142628c
parent 225
39e071e5adaf
parent 237
18e9f50c8d13
child 239
70cff21e5550

Merge

     1.1 --- a/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteStream.java	Sat Dec 18 18:29:58 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteStream.java	Mon Dec 20 17:18:56 2010 -0800
     1.3 @@ -30,12 +30,14 @@
     1.4  import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
     1.5  import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase;
     1.6  import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage;
     1.7 +import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
     1.8  import com.sun.corba.se.impl.encoding.BufferManagerWrite;
     1.9  import com.sun.corba.se.impl.encoding.ByteBufferWithInfo;
    1.10  import com.sun.corba.se.impl.encoding.CDROutputObject;
    1.11  import com.sun.corba.se.spi.orb.ORB;
    1.12  import com.sun.corba.se.pept.transport.Connection;
    1.13  import com.sun.corba.se.pept.encoding.OutputObject;
    1.14 +import org.omg.CORBA.SystemException;
    1.15  
    1.16  /**
    1.17   * Streaming buffer manager.
    1.18 @@ -66,7 +68,13 @@
    1.19          // Set the fragment's moreFragments field to true
    1.20          MessageBase.setFlag(bbwi.byteBuffer, Message.MORE_FRAGMENTS_BIT);
    1.21  
    1.22 -        sendFragment(false);
    1.23 +        try {
    1.24 +           sendFragment(false);
    1.25 +        } catch(SystemException se){
    1.26 +                orb.getPIHandler().invokeClientPIEndingPoint(
    1.27 +                        ReplyMessage.SYSTEM_EXCEPTION, se);
    1.28 +                throw se;
    1.29 +        }
    1.30  
    1.31          // Reuse the old buffer
    1.32  
     2.1 --- a/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Sat Dec 18 18:29:58 2010 -0800
     2.2 +++ b/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Mon Dec 20 17:18:56 2010 -0800
     2.3 @@ -85,6 +85,9 @@
     2.4  
     2.5      private static Hashtable translatedFields;
     2.6  
     2.7 +    /** true if represents enum type */
     2.8 +    private boolean isEnum;
     2.9 +
    2.10      private static final Bridge bridge =
    2.11          (Bridge)AccessController.doPrivileged(
    2.12              new PrivilegedAction() {
    2.13 @@ -359,6 +362,7 @@
    2.14          }
    2.15  
    2.16          name = cl.getName();
    2.17 +        isEnum = Enum.class.isAssignableFrom(cl);
    2.18          superclass = superdesc;
    2.19          serializable = serial;
    2.20          if (!forProxyClass) {
    2.21 @@ -401,7 +405,8 @@
    2.22          if (!serializable ||
    2.23              externalizable ||
    2.24              forProxyClass ||
    2.25 -            name.equals("java.lang.String")) {
    2.26 +            name.equals("java.lang.String") ||
    2.27 +            isEnum) {
    2.28              fields = NO_FIELDS;
    2.29          } else if (serializable) {
    2.30              /* Ask for permission to override field access checks.
    2.31 @@ -502,7 +507,7 @@
    2.32           *
    2.33           * NonSerializable classes have a serialVerisonUID of 0L.
    2.34           */
    2.35 -         if (isNonSerializable()) {
    2.36 +         if (isNonSerializable() || isEnum) {
    2.37               suid = 0L;
    2.38           } else {
    2.39               // Lookup special Serializable members using reflection.
     3.1 --- a/src/share/classes/com/sun/corba/se/impl/oa/poa/AOMEntry.java	Sat Dec 18 18:29:58 2010 -0800
     3.2 +++ b/src/share/classes/com/sun/corba/se/impl/oa/poa/AOMEntry.java	Mon Dec 20 17:18:56 2010 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -45,6 +45,10 @@
    3.11  import com.sun.corba.se.impl.orbutil.concurrent.Mutex ;
    3.12  import com.sun.corba.se.impl.orbutil.concurrent.CondVar ;
    3.13  
    3.14 +import org.omg.CORBA.SystemException ;
    3.15 +
    3.16 +import org.omg.PortableServer.POAPackage.ObjectAlreadyActive ;
    3.17 +
    3.18  /** AOMEntry represents a Servant or potential Servant in the ActiveObjectMap.
    3.19  * It may be in several states to allow for long incarnate or etherealize operations.
    3.20  * The methods on this class mostly represent input symbols to the state machine
    3.21 @@ -121,6 +125,12 @@
    3.22          }
    3.23      } ;
    3.24  
    3.25 +    private static Action oaaAction = new ActionBase( "throwObjectAlreadyActive" ) {
    3.26 +         public void doIt( FSM fsm, Input in ) {
    3.27 +             throw new RuntimeException( new ObjectAlreadyActive() ) ;
    3.28 +         }
    3.29 +    } ;
    3.30 +
    3.31      private static Guard waitGuard = new GuardBase( "wait" ) {
    3.32          public Guard.Result evaluate( FSM fsm, Input in ) {
    3.33              AOMEntry entry = (AOMEntry)fsm ;
    3.34 @@ -173,19 +183,23 @@
    3.35          engine.add( INCARN,  START_ETH, waitGuard,              null,               INCARN      ) ;
    3.36          engine.add( INCARN,  INC_DONE,                          null,               VALID       ) ;
    3.37          engine.add( INCARN,  INC_FAIL,                          decrementAction,    INVALID     ) ;
    3.38 +        engine.add( INCARN,  ACTIVATE,                          oaaAction,          INCARN      ) ;
    3.39  
    3.40          engine.add( VALID,   ENTER,                             incrementAction,    VALID       ) ;
    3.41          engine.add( VALID,   EXIT,                              decrementAction,    VALID       ) ;
    3.42          engine.add( VALID,   START_ETH, greaterZeroGuard,       null,               ETHP        ) ;
    3.43          engine.add( VALID,   START_ETH, zeroGuard,              null,               ETH         ) ;
    3.44 +        engine.add( VALID,   ACTIVATE,                          oaaAction,          VALID       ) ;
    3.45  
    3.46          engine.add( ETHP,    ENTER,     waitGuard,              null,               ETHP        ) ;
    3.47          engine.add( ETHP,    START_ETH,                         null,               ETHP        ) ;
    3.48          engine.add( ETHP,    EXIT,      greaterOneGuard,        decrementAction,    ETHP        ) ;
    3.49          engine.add( ETHP,    EXIT,      oneGuard,               decrementAction,    ETH         ) ;
    3.50 +        engine.add( ETHP,    ACTIVATE,                          oaaAction,          ETHP        ) ;
    3.51  
    3.52          engine.add( ETH,     START_ETH,                         null,               ETH         ) ;
    3.53          engine.add( ETH,     ETH_DONE,                          null,               DESTROYED   ) ;
    3.54 +        engine.add( ETH,     ACTIVATE,                          oaaAction,          ETH         ) ;
    3.55          engine.add( ETH,     ENTER,     waitGuard,              null,               ETH         ) ;
    3.56  
    3.57          engine.setDefault( DESTROYED, throwIllegalStateExceptionAction, DESTROYED ) ;
    3.58 @@ -217,7 +231,17 @@
    3.59      public void etherealizeComplete() { doIt( ETH_DONE ) ; }
    3.60      public void incarnateComplete() { doIt( INC_DONE ) ; }
    3.61      public void incarnateFailure() { doIt( INC_FAIL ) ; }
    3.62 -    public void activateObject() { doIt( ACTIVATE ) ; }
    3.63 +    public void activateObject() throws ObjectAlreadyActive {
    3.64 +         try {
    3.65 +             doIt( ACTIVATE ) ;
    3.66 +         } catch (RuntimeException exc) {
    3.67 +             Throwable thr = exc.getCause() ;
    3.68 +             if (thr instanceof ObjectAlreadyActive)
    3.69 +                 throw (ObjectAlreadyActive)thr ;
    3.70 +             else
    3.71 +                 throw exc ;
    3.72 +         }
    3.73 +    }
    3.74      public void enter() { doIt( ENTER ) ; }
    3.75      public void exit() { doIt( EXIT ) ; }
    3.76  }
     4.1 --- a/src/share/classes/com/sun/corba/se/impl/oa/poa/POAPolicyMediatorBase_R.java	Sat Dec 18 18:29:58 2010 -0800
     4.2 +++ b/src/share/classes/com/sun/corba/se/impl/oa/poa/POAPolicyMediatorBase_R.java	Mon Dec 20 17:18:56 2010 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -107,13 +107,9 @@
    4.11              throw new ServantAlreadyActive();
    4.12          ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;
    4.13  
    4.14 -        // Note that this can't happen for system assigned IDs since the
    4.15 -        // POA never hands out the same ID.  However, we make this redundant
    4.16 -        // check here to share the code.
    4.17 -        if (activeObjectMap.containsKey(key))
    4.18 -            throw new ObjectAlreadyActive() ;
    4.19 +        AOMEntry entry = activeObjectMap.get( key ) ;
    4.20  
    4.21 -        AOMEntry entry = activeObjectMap.get( key ) ;
    4.22 +        // Check for an ObjectAlreadyActive error
    4.23          entry.activateObject() ;
    4.24          activateServant( key, entry, servant ) ;
    4.25      }
     5.1 --- a/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Sat Dec 18 18:29:58 2010 -0800
     5.2 +++ b/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Mon Dec 20 17:18:56 2010 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -245,7 +245,14 @@
    5.11      // All access to resolver, localResolver, and urlOperation must be protected using
    5.12      // resolverLock.  Do not hold the ORBImpl lock while accessing
    5.13      // resolver, or deadlocks may occur.
    5.14 -    private Object resolverLock ;
    5.15 +    // Note that we now have separate locks for each resolver type.  This is due
    5.16 +    // to bug 6980681 and 6238477, which was caused by a deadlock while resolving a
    5.17 +    // corbaname: URL that contained a reference to the same ORB as the
    5.18 +    // ORB making the call to string_to_object.  This caused a deadlock between the
    5.19 +    // client thread holding the single lock for access to the urlOperation,
    5.20 +    // and the server thread handling the client is_a request waiting on the
    5.21 +    // same lock to access the localResolver.
    5.22 +
    5.23  
    5.24      // Used for resolver_initial_references and list_initial_services
    5.25      private Resolver resolver ;
    5.26 @@ -255,8 +262,14 @@
    5.27  
    5.28      // Converts strings to object references for resolvers and string_to_object
    5.29      private Operation urlOperation ;
    5.30 +    private final Object urlOperationLock = new java.lang.Object() ;
    5.31  
    5.32      private CorbaServerRequestDispatcher insNamingDelegate ;
    5.33 +    // resolverLock must be used for all access to either resolver or
    5.34 +    // localResolver, since it is possible for the resolver to indirectly
    5.35 +    // refer to the localResolver.  Also used to protect access to
    5.36 +    // insNamingDelegate.
    5.37 +    private final Object resolverLock = new Object() ;
    5.38  
    5.39      private TaggedComponentFactoryFinder taggedComponentFactoryFinder ;
    5.40  
    5.41 @@ -396,7 +409,6 @@
    5.42              }
    5.43          };
    5.44  
    5.45 -        resolverLock = new java.lang.Object() ;
    5.46  
    5.47          requestDispatcherRegistry = new RequestDispatcherRegistryImpl(
    5.48              this, ORBConstants.DEFAULT_SCID);
    5.49 @@ -832,7 +844,7 @@
    5.50          if (str == null)
    5.51              throw wrapper.nullParam() ;
    5.52  
    5.53 -        synchronized (resolverLock) {
    5.54 +        synchronized (urlOperationLock) {
    5.55              org.omg.CORBA.Object obj = (org.omg.CORBA.Object)op.operate( str ) ;
    5.56              return obj ;
    5.57          }
    5.58 @@ -1778,7 +1790,7 @@
    5.59       */
    5.60      public void setURLOperation( Operation stringToObject )
    5.61      {
    5.62 -        synchronized (resolverLock) {
    5.63 +        synchronized (urlOperationLock) {
    5.64              urlOperation = stringToObject ;
    5.65          }
    5.66      }
    5.67 @@ -1788,7 +1800,7 @@
    5.68       */
    5.69      public Operation getURLOperation()
    5.70      {
    5.71 -        synchronized (resolverLock) {
    5.72 +        synchronized (urlOperationLock) {
    5.73              return urlOperation ;
    5.74          }
    5.75      }
     6.1 --- a/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java	Sat Dec 18 18:29:58 2010 -0800
     6.2 +++ b/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java	Mon Dec 20 17:18:56 2010 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -122,9 +122,6 @@
    6.11      implements
    6.12          ClientRequestDispatcher
    6.13  {
    6.14 -    // Used for locking
    6.15 -    private Object lock = new Object();
    6.16 -
    6.17      public OutputObject beginRequest(Object self, String opName,
    6.18                                       boolean isOneWay, ContactInfo contactInfo)
    6.19      {
    6.20 @@ -151,7 +148,8 @@
    6.21  
    6.22          // This locking is done so that multiple connections are not created
    6.23          // for the same endpoint
    6.24 -        synchronized (lock) {
    6.25 +        //6929137 - Synchronized on contactInfo to avoid blocking across multiple endpoints
    6.26 +        synchronized (contactInfo) {
    6.27              if (contactInfo.isConnectionBased()) {
    6.28                  if (contactInfo.shouldCacheConnection()) {
    6.29                      connection = (CorbaConnection)
    6.30 @@ -256,7 +254,7 @@
    6.31          registerWaiter(messageMediator);
    6.32  
    6.33          // Do connection reclaim now
    6.34 -        synchronized (lock) {
    6.35 +        synchronized (contactInfo) {
    6.36              if (contactInfo.isConnectionBased()) {
    6.37                  if (contactInfo.shouldCacheConnection()) {
    6.38                      OutboundConnectionCache connectionCache =
    6.39 @@ -387,11 +385,15 @@
    6.40              boolean retry  =
    6.41                  getContactInfoListIterator(orb)
    6.42                      .reportException(messageMediator.getContactInfo(), e);
    6.43 +
    6.44 +            //Bug 6382377: must not lose exception in PI
    6.45 +
    6.46 +            // Must run interceptor end point before retrying.
    6.47 +            Exception newException =
    6.48 +                    orb.getPIHandler().invokeClientPIEndingPoint(
    6.49 +                    ReplyMessage.SYSTEM_EXCEPTION, e);
    6.50 +
    6.51              if (retry) {
    6.52 -                // Must run interceptor end point before retrying.
    6.53 -                Exception newException =
    6.54 -                    orb.getPIHandler().invokeClientPIEndingPoint(
    6.55 -                        ReplyMessage.SYSTEM_EXCEPTION, e);
    6.56                  if (newException == e) {
    6.57                      continueOrThrowSystemOrRemarshal(messageMediator,
    6.58                                                       new RemarshalException());
    6.59 @@ -400,6 +402,14 @@
    6.60                                                       newException);
    6.61                  }
    6.62              } else {
    6.63 +                if (newException instanceof RuntimeException){
    6.64 +                    throw (RuntimeException)newException;
    6.65 +                }
    6.66 +                else if (newException instanceof RemarshalException)
    6.67 +                {
    6.68 +                    throw (RemarshalException)newException;
    6.69 +                }
    6.70 +
    6.71                  // NOTE: Interceptor ending point will run in releaseReply.
    6.72                  throw e;
    6.73              }
     7.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/CorbaConnectionCacheBase.java	Sat Dec 18 18:29:58 2010 -0800
     7.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/CorbaConnectionCacheBase.java	Mon Dec 20 17:18:56 2010 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -34,6 +34,7 @@
    7.11  
    7.12  import com.sun.corba.se.spi.logging.CORBALogDomains;
    7.13  import com.sun.corba.se.spi.orb.ORB;
    7.14 +import com.sun.corba.se.spi.transport.CorbaConnection;
    7.15  import com.sun.corba.se.spi.transport.CorbaConnectionCache;
    7.16  
    7.17  import com.sun.corba.se.impl.logging.ORBUtilSystemException;
    7.18 @@ -87,6 +88,14 @@
    7.19          }
    7.20      }
    7.21  
    7.22 +    public void close() {
    7.23 +        synchronized (backingStore()) {
    7.24 +            for (Object obj : values()) {
    7.25 +                ((CorbaConnection)obj).closeConnectionResources() ;
    7.26 +            }
    7.27 +        }
    7.28 +    }
    7.29 +
    7.30      public long numberOfIdleConnections()
    7.31      {
    7.32          long count = 0;
     8.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java	Sat Dec 18 18:29:58 2010 -0800
     8.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java	Mon Dec 20 17:18:56 2010 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2003, 2010 Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -38,6 +38,7 @@
    8.11  import org.omg.CORBA.CompletionStatus;
    8.12  
    8.13  import com.sun.corba.se.pept.transport.Acceptor;
    8.14 +import com.sun.corba.se.pept.transport.ConnectionCache;
    8.15  import com.sun.corba.se.pept.transport.ByteBufferPool;
    8.16  import com.sun.corba.se.pept.transport.ContactInfo;
    8.17  import com.sun.corba.se.pept.transport.InboundConnectionCache;
    8.18 @@ -49,6 +50,8 @@
    8.19  import com.sun.corba.se.spi.orb.ORB;
    8.20  import com.sun.corba.se.spi.transport.CorbaAcceptor;
    8.21  import com.sun.corba.se.spi.transport.CorbaTransportManager;
    8.22 +import com.sun.corba.se.pept.transport.Connection;
    8.23 +import com.sun.corba.se.pept.transport.ConnectionCache;
    8.24  
    8.25  // REVISIT - impl/poa specific:
    8.26  import com.sun.corba.se.impl.oa.poa.Policies;
    8.27 @@ -182,6 +185,12 @@
    8.28              if (orb.transportDebugFlag) {
    8.29                  dprint(".close->");
    8.30              }
    8.31 +            for (Object cc : outboundConnectionCaches.values()) {
    8.32 +                ((ConnectionCache)cc).close() ;
    8.33 +            }
    8.34 +            for (Object cc : inboundConnectionCaches.values()) {
    8.35 +                ((ConnectionCache)cc).close() ;
    8.36 +            }
    8.37              getSelector(0).close();
    8.38          } finally {
    8.39              if (orb.transportDebugFlag) {
     9.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Sat Dec 18 18:29:58 2010 -0800
     9.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Mon Dec 20 17:18:56 2010 -0800
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -32,6 +32,7 @@
    9.11  import java.nio.channels.Selector;
    9.12  import java.util.ArrayList;
    9.13  import java.util.HashMap;
    9.14 +import java.util.Map;
    9.15  import java.util.Iterator;
    9.16  import java.util.List;
    9.17  
    9.18 @@ -66,7 +67,7 @@
    9.19      private List deferredRegistrations;
    9.20      private List interestOpsList;
    9.21      private HashMap listenerThreads;
    9.22 -    private HashMap readerThreads;
    9.23 +    private Map readerThreads;
    9.24      private boolean selectorStarted;
    9.25      private boolean closed;
    9.26      private ORBUtilSystemException wrapper ;
    9.27 @@ -81,7 +82,7 @@
    9.28          deferredRegistrations = new ArrayList();
    9.29          interestOpsList = new ArrayList();
    9.30          listenerThreads = new HashMap();
    9.31 -        readerThreads = new HashMap();
    9.32 +        readerThreads = java.util.Collections.synchronizedMap(new HashMap());
    9.33          closed = false;
    9.34          wrapper = ORBUtilSystemException.get(orb,CORBALogDomains.RPC_TRANSPORT);
    9.35      }
    9.36 @@ -178,8 +179,13 @@
    9.37          }
    9.38  
    9.39          if (eventHandler.shouldUseSelectThreadToWait()) {
    9.40 -            SelectionKey selectionKey = eventHandler.getSelectionKey();
    9.41 -            selectionKey.cancel();
    9.42 +            SelectionKey selectionKey ;
    9.43 +            synchronized(deferredRegistrations) {
    9.44 +                selectionKey = eventHandler.getSelectionKey();
    9.45 +            }
    9.46 +            if (selectionKey != null) {
    9.47 +                selectionKey.cancel();
    9.48 +            }
    9.49              selector.wakeup();
    9.50              return;
    9.51          }
    10.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java	Sat Dec 18 18:29:58 2010 -0800
    10.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java	Mon Dec 20 17:18:56 2010 -0800
    10.3 @@ -811,6 +811,7 @@
    10.4                      dprint(".close: " + this, e);
    10.5                  }
    10.6              }
    10.7 +            closeConnectionResources();
    10.8          } finally {
    10.9              if (orb.transportDebugFlag) {
   10.10                  dprint(".close<-: " + this);
   10.11 @@ -818,6 +819,28 @@
   10.12          }
   10.13      }
   10.14  
   10.15 +    public void closeConnectionResources() {
   10.16 +           if (orb.transportDebugFlag) {
   10.17 +               dprint(".closeConnectionResources->: " + this);
   10.18 +           }
   10.19 +           Selector selector = orb.getTransportManager().getSelector(0);
   10.20 +           selector.unregisterForEvent(this);
   10.21 +           try {
   10.22 +             if (socketChannel != null)
   10.23 +              socketChannel.close() ;
   10.24 +                if (socket != null && !socket.isClosed())
   10.25 +                socket.close() ;
   10.26 +           } catch (IOException e) {
   10.27 +             if (orb.transportDebugFlag) {
   10.28 +                 dprint( ".closeConnectionResources: " + this, e ) ;
   10.29 +             }
   10.30 +           }
   10.31 +           if (orb.transportDebugFlag) {
   10.32 +               dprint(".closeConnectionResources<-: " + this);
   10.33 +           }
   10.34 +     }
   10.35 +
   10.36 +
   10.37      public Acceptor getAcceptor()
   10.38      {
   10.39          return acceptor;
    11.1 --- a/src/share/classes/com/sun/corba/se/pept/transport/ConnectionCache.java	Sat Dec 18 18:29:58 2010 -0800
    11.2 +++ b/src/share/classes/com/sun/corba/se/pept/transport/ConnectionCache.java	Mon Dec 20 17:18:56 2010 -0800
    11.3 @@ -41,6 +41,12 @@
    11.4      public long numberOfBusyConnections();
    11.5  
    11.6      public boolean reclaim();
    11.7 +
    11.8 +    /** Close all connections in the connection cache.
    11.9 +     * This is used as a final cleanup, and will result
   11.10 +     * in abrupt termination of any pending communications.
   11.11 +     */
   11.12 +    public void close();
   11.13  }
   11.14  
   11.15  // End of file.
    12.1 --- a/src/share/classes/com/sun/corba/se/spi/transport/CorbaConnection.java	Sat Dec 18 18:29:58 2010 -0800
    12.2 +++ b/src/share/classes/com/sun/corba/se/spi/transport/CorbaConnection.java	Mon Dec 20 17:18:56 2010 -0800
    12.3 @@ -163,6 +163,10 @@
    12.4      // REVISIT - MessageMediator parameter?
    12.5      public void serverRequestProcessingBegins();
    12.6      public void serverRequestProcessingEnds();
    12.7 +
    12.8 +    /** Clean up all connection resources.  Used when shutting down an ORB.
    12.9 +     */
   12.10 +    public void closeConnectionResources();
   12.11  }
   12.12  
   12.13  // End of file.
    13.1 --- a/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Stub.java	Sat Dec 18 18:29:58 2010 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Stub.java	Mon Dec 20 17:18:56 2010 -0800
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -344,17 +344,27 @@
   13.11      stream.println ("     String str = s.readUTF ();");
   13.12      stream.println ("     String[] args = null;");
   13.13      stream.println ("     java.util.Properties props = null;");
   13.14 -    stream.println ("     org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);");
   13.15 +    stream.println ("     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);");
   13.16 +    stream.println ("   try {");
   13.17 +    stream.println ("     org.omg.CORBA.Object obj = orb.string_to_object (str);");
   13.18      stream.println ("     org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();");
   13.19      stream.println ("     _set_delegate (delegate);");
   13.20 +    stream.println ("   } finally {");
   13.21 +    stream.println ("     orb.destroy() ;");
   13.22 +    stream.println ("   }");
   13.23      stream.println ("  }");
   13.24      stream.println ();
   13.25      stream.println ("  private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException");
   13.26      stream.println ("  {");
   13.27      stream.println ("     String[] args = null;");
   13.28      stream.println ("     java.util.Properties props = null;");
   13.29 -    stream.println ("     String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);");
   13.30 +    stream.println ("     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);");
   13.31 +    stream.println ("   try {");
   13.32 +    stream.println ("     String str = orb.object_to_string (this);");
   13.33      stream.println ("     s.writeUTF (str);");
   13.34 +    stream.println ("   } finally {");
   13.35 +    stream.println ("     orb.destroy() ;");
   13.36 +    stream.println ("   }");
   13.37      stream.println ("  }");
   13.38    }
   13.39  

mercurial