Program: 74972
Project: 74972
Buggy source:
/** 
 * Get or put token(s) to the array of receivers. This method is commonly used by   {@link #getFromAll(Receiver[][],RendezvousDirector)},  {@link #getFromAny(Receiver[][],RendezvousDirector)},  {@link #putToAll(Token[][],Receiver[][],RendezvousDirector)} and{@link #putToAny(Token,Receiver[][],RendezvousDirector)}. If the tokens parameter is null, it does a get. isCondition indicates whether the get is from all or from any. If the tokens parameter is a single token (of type   {@link Token}), it does put to any with that token. If the tokens parameter is a two-dimentional array of tokens, it does put to all with those tokens. This method does not return until the get or put is finished.
 * @param receivers The receivers to be got from or put to.
 * @param director The director.
 * @param tokens null if this method is used to get tokens; a token ofthis method is used to put to any of the receivers; or a two-dimentional array of tokens if this method is used to put to all of the receivers.
 * @param isConditional Whether the get or put is conditional.
 * @return The map of results on the receivers that participate in therendezvous. Keys of the map are receivers; values of the map are the tokens on those receivers.
 * @exception IllegalActionException If the token is not acceptableto one of the ports (e.g., wrong type). This can happen only if the operation is put to all or put to any.
 * @exception TerminateProcessException If the actor towhich this receiver belongs is to be terminated.
 */
private static Map _getOrPutTokens(Receiver[][] getReceivers,Receiver[][] putReceivers,RendezvousDirector director,Object tokens,int flag) throws IllegalActionException, TerminateProcessException {
  Map result=null;
synchronized (director) {
    Thread theThread=Thread.currentThread();
    Token token=tokens instanceof Token ? (Token)tokens : null;
    Token[][] tokenArray=tokens instanceof Token[][] ? (Token[][])tokens : null;
    boolean isGet=(flag & GET) == GET;
    boolean isPut=(flag & PUT) == PUT;
    boolean isSymmetric=isPut && isGet;
    if (isGet) {
      for (int i=0; i < getReceivers.length; i++) {
        if (getReceivers[i] != null) {
          for (int j=0; j < getReceivers[i].length; j++) {
            if (getReceivers[i][j] != null) {
              RendezvousReceiver castReceiver=(RendezvousReceiver)getReceivers[i][j];
              castReceiver._getWaiting=theThread;
              castReceiver._getReceivers=getReceivers;
              castReceiver._getConditional=((flag & GET_CONDITIONAL) == GET_CONDITIONAL);
              if (isSymmetric) {
                castReceiver._symmetricPutReceivers=putReceivers;
              }
            }
          }
        }
      }
    }
    if (isPut) {
      for (int i=0; i < putReceivers.length; i++) {
        if (putReceivers[i] != null) {
          for (int j=0; j < putReceivers[i].length; j++) {
            if (putReceivers[i][j] != null) {
              RendezvousReceiver castReceiver=(RendezvousReceiver)putReceivers[i][j];
              castReceiver._putWaiting=theThread;
              castReceiver._putReceivers=putReceivers;
              IOPort port=castReceiver.getContainer();
              if ((flag & PUT_CONDITIONAL) == PUT_CONDITIONAL) {
                castReceiver._putConditional=true;
                castReceiver._token=token == null ? null : port.convert(token);
              }
 else {
                castReceiver._putConditional=false;
                try {
                  token=tokenArray[i][j];
                }
 catch (                Throwable e) {
                }
                castReceiver._token=token == null ? null : port.convert(token);
              }
              if (isSymmetric) {
                castReceiver._symmetricGetReceivers=getReceivers;
              }
            }
          }
        }
      }
    }
    Set rendezvousReceivers;
    if (getReceivers != null) {
      rendezvousReceivers=_receiversReadyToCommit(getReceivers,false);
    }
 else {
      rendezvousReceivers=_receiversReadyToCommit(putReceivers,true);
    }
    if (rendezvousReceivers == null) {
      director.threadBlocked(theThread,null);
      while (result == null) {
        waitForChange(director);
        result=(Map)_getData(theThread);
      }
      _setData(theThread,null);
    }
 else {
      _commitRendezvous(rendezvousReceivers,director);
      result=(Map)_setData(theThread,null);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Get or put token(s) to the array of receivers. This method is commonly used by   {@link #getFromAll(Receiver[][],RendezvousDirector)},  {@link #getFromAny(Receiver[][],RendezvousDirector)},  {@link #putToAll(Token[][],Receiver[][],RendezvousDirector)} and{@link #putToAny(Token,Receiver[][],RendezvousDirector)}. If the tokens parameter is null, it does a get. isCondition indicates whether the get is from all or from any. If the tokens parameter is a single token (of type   {@link Token}), it does put to any with that token. If the tokens parameter is a two-dimentional array of tokens, it does put to all with those tokens. This method does not return until the get or put is finished.
 * @param receivers The receivers to be got from or put to.
 * @param director The director.
 * @param tokens null if this method is used to get tokens; a token ofthis method is used to put to any of the receivers; or a two-dimentional array of tokens if this method is used to put to all of the receivers.
 * @param isConditional Whether the get or put is conditional.
 * @return The map of results on the receivers that participate in therendezvous. Keys of the map are receivers; values of the map are the tokens on those receivers.
 * @exception IllegalActionException If the token is not acceptableto one of the ports (e.g., wrong type). This can happen only if the operation is put to all or put to any.
 * @exception TerminateProcessException If the actor towhich this receiver belongs is to be terminated.
 */
private static Map _getOrPutTokens(Receiver[][] getReceivers,Receiver[][] putReceivers,RendezvousDirector director,Object tokens,int flag) throws IllegalActionException, TerminateProcessException {
  Map result=null;
synchronized (director) {
    Thread theThread=Thread.currentThread();
    Token token=tokens instanceof Token ? (Token)tokens : null;
    Token[][] tokenArray=tokens instanceof Token[][] ? (Token[][])tokens : null;
    boolean isGet=(flag & GET) == GET;
    boolean isPut=(flag & PUT) == PUT;
    boolean isGetConditional=(flag & GET_CONDITIONAL) == GET_CONDITIONAL;
    boolean isPutConditional=(flag & PUT_CONDITIONAL) == PUT_CONDITIONAL;
    boolean isSymmetric=isPut && isGet;
    if (isGet) {
      for (int i=0; i < getReceivers.length; i++) {
        if (getReceivers[i] != null) {
          for (int j=0; j < getReceivers[i].length; j++) {
            if (getReceivers[i][j] != null) {
              RendezvousReceiver castReceiver=(RendezvousReceiver)getReceivers[i][j];
              castReceiver._getWaiting=theThread;
              castReceiver._getReceivers=getReceivers;
              castReceiver._getConditional=isGetConditional;
              if (isSymmetric) {
                castReceiver._symmetricPutReceivers=putReceivers;
              }
            }
          }
        }
      }
    }
    if (isPut) {
      for (int i=0; i < putReceivers.length; i++) {
        if (putReceivers[i] != null) {
          for (int j=0; j < putReceivers[i].length; j++) {
            if (putReceivers[i][j] != null) {
              RendezvousReceiver castReceiver=(RendezvousReceiver)putReceivers[i][j];
              castReceiver._putWaiting=theThread;
              castReceiver._putReceivers=putReceivers;
              IOPort port=castReceiver.getContainer();
              if (isPutConditional) {
                castReceiver._putConditional=true;
                castReceiver._token=token == null ? null : port.convert(token);
              }
 else {
                castReceiver._putConditional=false;
                try {
                  token=tokenArray[i][j];
                }
 catch (                Throwable e) {
                }
                castReceiver._token=token == null ? null : port.convert(token);
              }
              if (isSymmetric) {
                castReceiver._symmetricGetReceivers=getReceivers;
              }
            }
          }
        }
      }
    }
    Set rendezvousReceivers;
    if (getReceivers != null) {
      rendezvousReceivers=_receiversReadyToCommit(getReceivers,false);
    }
 else {
      rendezvousReceivers=_receiversReadyToCommit(putReceivers,true);
    }
    if (rendezvousReceivers == null) {
      director.threadBlocked(theThread,null);
      while (result == null) {
        waitForChange(director);
        result=(Map)_getData(theThread);
      }
      _setData(theThread,null);
    }
 else {
      _commitRendezvous(rendezvousReceivers,director);
      result=(Map)_setData(theThread,null);
    }
  }
  return result;
}