Program: 134806
Project: 134806
Buggy source:
/** 
 * Deactivates a component. <ol> <li>First the component's POA manager is put into inactive state, so that all incoming calls to this component are rejected.  However, we wait for currently executing calls to finish, with a timeout as described below. <ul> <li>Rejection applies to requests already received and queued by the ORB (but that have not started executing),  as well as to requests that clients will send in the future.  <li>Note that entering into the inactive state may take forever if the component hangs in a functional call. <li>Therefore we use a timeout to proceed in such cases where POA manager deactivation does not happen in time. This bears the risk of undesirable behavior caused by calling the   {@link ComponentLifecycle#cleanUp() cleanUp} method while other threads still perform functional calls on the component. </ul> <li>Second the component itself is deactivated: <ul> <li>The lifecycle method  {@link ComponentLifecycle#cleanUp() cleanUp} is called, currently without enforcing a timeout.<li>TODO: use a timeout, unless we decide that a client-side timeout for releaseComponent is good enough. </ul> <li>Third the component is disconnected from CORBA ("etherealized" from the POA). <ul> <li>Note that also etherealization may take forever if the component hangs in a call. <li>Therefore we use a timeout to proceed with deactivation in such cases where etherealization does not happen in time. <li>Currently a component that failed to etherealize in time can stay active as long as the container is alive. TODO: check if using the "container sealant" we can identify and stop the active ORB threads. </ul> </ol>    This method logs errors as FINER if they also cause an exception, and as WARNING if they cannot lead to an exception because other more important error conditions are present.
 * @throws ComponentDeactivationUncleanEx , ComponentDeactivationFailedEx 
 */
void deactivateComponent() throws AcsJComponentDeactivationUncleanEx, AcsJComponentDeactivationFailedEx {
  if (m_containerLogger.isLoggable(Level.FINER)) {
    m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ getHandle());
  }
  AcsJComponentDeactivationUncleanEx deactivationUncleanEx=null;
  AcsJComponentDeactivationFailedEx deactivationFailedEx=null;
  try {
    int deactivateTimeoutMillis=10000;
    boolean isInactive=acsCorba.deactivateComponentPOAManager(m_componentPOA,m_compInstanceName,deactivateTimeoutMillis);
    if (isInactive && m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str");
    }
 else     if (!isInactive) {
      String msg="String_Node_Str" + m_compInstanceName + "String_Node_Str"+ deactivateTimeoutMillis+ "String_Node_Str";
      m_containerLogger.warning(msg);
      deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx();
      deactivationUncleanEx.setCURL(m_compInstanceName);
      deactivationUncleanEx.setReason(msg);
    }
    ClassLoader contCL=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(m_componentClassLoader);
    try {
      m_component.cleanUp();
    }
 catch (    Throwable thr) {
      m_containerLogger.log(Level.FINE,"String_Node_Str" + m_compInstanceName,thr);
      deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx(thr);
      deactivationUncleanEx.setCURL(m_compInstanceName);
    }
 finally {
      Thread.currentThread().setContextClassLoader(contCL);
      try {
        m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_DEFUNCT);
      }
 catch (      ComponentLifecycleException ex) {
        if (deactivationUncleanEx == null) {
          deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx(ex);
          deactivationUncleanEx.setCURL(m_compInstanceName);
        }
 else {
          m_containerLogger.log(Level.WARNING,"String_Node_Str" + m_compInstanceName,ex);
        }
      }
      m_containerServices.cleanUp();
      m_threadFactory.cleanUp();
    }
    int etherealizeTimeoutMillis=1000;
    boolean isEtherealized=acsCorba.destroyComponentPOA(m_componentPOA,compServantManager,etherealizeTimeoutMillis);
    if (isEtherealized && m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str");
    }
 else     if (!isEtherealized) {
      m_containerLogger.warning("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ etherealizeTimeoutMillis+ "String_Node_Str");
      deactivationFailedEx=new AcsJComponentDeactivationFailedEx();
      deactivationFailedEx.setCURL(m_compInstanceName);
      deactivationFailedEx.setReason("String_Node_Str" + etherealizeTimeoutMillis + "String_Node_Str");
      deactivationFailedEx.setIsPermanentFailure(true);
    }
    if (m_componentClassLoader instanceof AcsComponentClassLoader) {
      try {
        ((AcsComponentClassLoader)m_componentClassLoader).close();
      }
 catch (      IOException ex) {
        m_containerLogger.log(Level.WARNING,"String_Node_Str",ex);
      }
    }
  }
 catch (  RuntimeException ex) {
    if (deactivationFailedEx == null) {
      deactivationFailedEx=new AcsJComponentDeactivationFailedEx(ex);
      deactivationFailedEx.setCURL(m_compInstanceName);
      deactivationFailedEx.setReason("String_Node_Str");
    }
 else {
      m_containerLogger.log(Level.WARNING,"String_Node_Str" + m_compInstanceName,ex);
    }
  }
  if (deactivationFailedEx != null) {
    if (m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.log(Level.FINER,"String_Node_Str" + m_compInstanceName + "String_Node_Str"+ "String_Node_Str",deactivationFailedEx);
    }
    throw deactivationFailedEx;
  }
  if (deactivationUncleanEx != null) {
    if (m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.log(Level.FINER,"String_Node_Str" + m_compInstanceName + "String_Node_Str"+ "String_Node_Str",deactivationFailedEx);
    }
    throw deactivationUncleanEx;
  }
  if (m_containerLogger.isLoggable(Level.FINER)) {
    m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ getHandle());
  }
}

Fixed version (ground truth):
/** 
 * Deactivates a component. <ol> <li>First the component's POA manager is put into inactive state, so that all incoming calls to this component are rejected.  However, we wait for currently executing calls to finish, with a timeout as described below. <ul> <li>Rejection applies to requests already received and queued by the ORB (but that have not started executing),  as well as to requests that clients will send in the future.  <li>Note that entering into the inactive state may take forever if the component hangs in a functional call. <li>Therefore we use a timeout to proceed in such cases where POA manager deactivation does not happen in time. This bears the risk of undesirable behavior caused by calling the   {@link ComponentLifecycle#cleanUp() cleanUp} method while other threads still perform functional calls on the component. </ul> <li>Second the component itself is deactivated: <ul> <li>The lifecycle method  {@link ComponentLifecycle#cleanUp() cleanUp} is called, currently without enforcing a timeout.<li>TODO: use a timeout, unless we decide that a client-side timeout for releaseComponent is good enough. </ul> <li>Third the component is disconnected from CORBA ("etherealized" from the POA). <ul> <li>Note that also etherealization may take forever if the component hangs in a call. <li>Therefore we use a timeout to proceed with deactivation in such cases where etherealization does not happen in time. <li>Currently a component that failed to etherealize in time can stay active as long as the container is alive. TODO: check if using the "container sealant" we can identify and stop the active ORB threads. </ul> </ol>    This method logs errors as FINER if they also cause an exception, and as WARNING if they cannot lead to an exception because other more important error conditions are present.
 * @throws ComponentDeactivationUncleanEx , ComponentDeactivationFailedEx 
 */
void deactivateComponent() throws AcsJComponentDeactivationUncleanEx, AcsJComponentDeactivationFailedEx {
  if (m_containerLogger.isLoggable(Level.FINER)) {
    m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ getHandle());
  }
  AcsJComponentDeactivationUncleanEx deactivationUncleanEx=null;
  AcsJComponentDeactivationFailedEx deactivationFailedEx=null;
  try {
    int deactivateTimeoutMillis=10000;
    boolean isInactive=acsCorba.deactivateComponentPOAManager(m_componentPOA,m_compInstanceName,deactivateTimeoutMillis);
    if (isInactive && m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str");
    }
 else     if (!isInactive) {
      String msg="String_Node_Str" + m_compInstanceName + "String_Node_Str"+ deactivateTimeoutMillis+ "String_Node_Str";
      m_containerLogger.warning(msg);
      deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx();
      deactivationUncleanEx.setCURL(m_compInstanceName);
      deactivationUncleanEx.setReason(msg);
    }
    ClassLoader contCL=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(m_componentClassLoader);
    try {
      m_component.cleanUp();
    }
 catch (    Throwable thr) {
      m_containerLogger.log(Level.FINE,"String_Node_Str" + m_compInstanceName,thr);
      deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx(thr);
      deactivationUncleanEx.setCURL(m_compInstanceName);
    }
 finally {
      Thread.currentThread().setContextClassLoader(contCL);
      try {
        m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_DEFUNCT);
      }
 catch (      ComponentLifecycleException ex) {
        if (deactivationUncleanEx == null) {
          deactivationUncleanEx=new AcsJComponentDeactivationUncleanEx(ex);
          deactivationUncleanEx.setCURL(m_compInstanceName);
        }
 else {
          m_containerLogger.log(Level.WARNING,"String_Node_Str" + m_compInstanceName,ex);
        }
      }
      m_containerServices.cleanUp();
      m_threadFactory.cleanUp();
    }
    int etherealizeTimeoutMillis=1000;
    boolean isEtherealized=acsCorba.destroyComponentPOA(m_componentPOA,compServantManager,etherealizeTimeoutMillis);
    if (isEtherealized && m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str");
    }
 else     if (!isEtherealized) {
      m_containerLogger.warning("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ etherealizeTimeoutMillis+ "String_Node_Str");
      deactivationFailedEx=new AcsJComponentDeactivationFailedEx();
      deactivationFailedEx.setCURL(m_compInstanceName);
      deactivationFailedEx.setReason("String_Node_Str" + etherealizeTimeoutMillis + "String_Node_Str");
      deactivationFailedEx.setIsPermanentFailure(true);
    }
    if (m_componentClassLoader instanceof AcsComponentClassLoader) {
      try {
        ((AcsComponentClassLoader)m_componentClassLoader).close();
      }
 catch (      IOException ex) {
        m_containerLogger.log(Level.WARNING,"String_Node_Str",ex);
      }
    }
  }
 catch (  RuntimeException ex) {
    if (deactivationFailedEx == null) {
      deactivationFailedEx=new AcsJComponentDeactivationFailedEx(ex);
      deactivationFailedEx.setCURL(m_compInstanceName);
      deactivationFailedEx.setReason("String_Node_Str");
    }
 else {
      m_containerLogger.log(Level.WARNING,"String_Node_Str" + m_compInstanceName,ex);
    }
  }
  if (deactivationFailedEx != null) {
    if (m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.log(Level.FINER,"String_Node_Str" + m_compInstanceName + "String_Node_Str"+ "String_Node_Str",deactivationFailedEx);
    }
    throw deactivationFailedEx;
  }
  if (deactivationUncleanEx != null) {
    if (m_containerLogger.isLoggable(Level.FINER)) {
      m_containerLogger.log(Level.FINER,"String_Node_Str" + m_compInstanceName + "String_Node_Str"+ "String_Node_Str",deactivationUncleanEx);
    }
    throw deactivationUncleanEx;
  }
  if (m_containerLogger.isLoggable(Level.FINER)) {
    m_containerLogger.finer("String_Node_Str" + m_compInstanceName + "String_Node_Str"+ getHandle());
  }
}