Program: 95138
Project: 95138
Buggy source:
/** 
 * Initialize replicas of this channel.  This method is only called if isPrimary() returns false.  It is called from within the initialize method, immediately after super.initialize but before the listener for this  channel is notified of initialization.  If this method throws a SharedObjectInitException, then initialization of the replica is halted and the remote transaction creating the replica will be  aborted. <p> Note that this implementation checks for the existence of the RECEIVER_ID_PROPERTY on the replica's properties, and if the property contains a valid ID will  <ul> <li>lookup the IChannel on the given container via IChannelContainer.getID(ID)</li> <li>call IChannel.getListener() to retrieve the listener for the channel returned</li> <li>set the listener for this object to the value returned from IChannel.getListener()</li> </ul>
 * @throws SharedObjectInitException if the replica initialization should fail
 */
protected void initializeReplicaChannel() throws SharedObjectInitException {
  Map properties=getConfig().getProperties();
  ID rcvr=null;
  try {
    rcvr=(ID)properties.get(RECEIVER_ID_PROPERTY);
  }
 catch (  ClassCastException e) {
    throw new SharedObjectInitException("String_Node_Str");
  }
  IChannelListener l=null;
  if (rcvr != null) {
    IChannelContainer container=(IChannelContainer)getContext().getAdapter(IChannelContainer.class);
    if (container == null)     throw new SharedObjectInitException("String_Node_Str");
    final IChannel receiver=container.getChannel(rcvr);
    if (receiver == null)     throw new SharedObjectInitException("String_Node_Str");
    setChannelListener(receiver.getListener());
  }
  if (l == null) {
    setChannelListener(new IChannelListener(){
      public void handleChannelEvent(      IChannelEvent event){
        receiveUndeliveredChannelEvent(event);
      }
    }
);
  }
 else {
    this.listener=l;
  }
}

Fixed version (ground truth):
/** 
 * Initialize replicas of this channel.  This method is only called if isPrimary() returns false.  It is called from within the initialize method, immediately after super.initialize but before the listener for this  channel is notified of initialization.  If this method throws a SharedObjectInitException, then initialization of the replica is halted and the remote transaction creating the replica will be  aborted. <p> Note that this implementation checks for the existence of the RECEIVER_ID_PROPERTY on the replica's properties, and if the property contains a valid ID will  <ul> <li>lookup the IChannel on the given container via IChannelContainer.getID(ID)</li> <li>call IChannel.getListener() to retrieve the listener for the channel returned</li> <li>set the listener for this object to the value returned from IChannel.getListener()</li> </ul>
 * @throws SharedObjectInitException if the replica initialization should fail
 */
protected void initializeReplicaChannel() throws SharedObjectInitException {
  Map properties=getConfig().getProperties();
  ID rcvr=null;
  try {
    rcvr=(ID)properties.get(RECEIVER_ID_PROPERTY);
  }
 catch (  ClassCastException e) {
    throw new SharedObjectInitException("String_Node_Str");
  }
  IChannelListener l=null;
  if (rcvr != null) {
    IChannelContainer container=(IChannelContainer)getContext().getAdapter(IChannelContainer.class);
    if (container == null)     throw new SharedObjectInitException("String_Node_Str");
    final IChannel receiver=container.getChannel(rcvr);
    if (receiver == null)     throw new SharedObjectInitException("String_Node_Str");
    setChannelListener(receiver.getListener());
  }
  if (listener == null) {
    setChannelListener(new IChannelListener(){
      public void handleChannelEvent(      IChannelEvent event){
        receiveUndeliveredChannelEvent(event);
      }
    }
);
  }
 else {
    this.listener=l;
  }
}