Program: 72661
Project: 72661
Buggy source:
public void fire() throws IllegalActionException {
  super.fire();
  boolean portTypeDefined=false;
synchronized (_receivedTokens) {
    if (_receivedTokens.size() > 0) {
      if (_receivedTokens.keySet().size() > 0) {
        for (        String identifier : _receivedTokens.keySet()) {
          TypedIOPort destinationPort=(TypedIOPort)this.getPort(identifier);
          if (destinationPort == null || !destinationPort.isOutput()) {
            _receivedTokens.remove(identifier);
          }
 else {
            if (destinationPort.getType() != null) {
              portTypeDefined=true;
            }
            for (            Object token : _receivedTokens.get(identifier)) {
              if (token instanceof Double) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.DOUBLE);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new DoubleToken((Double)token));
              }
 else               if (token instanceof Integer) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.INT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new IntToken((Integer)token));
              }
 else               if (token instanceof String) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.STRING);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new StringToken((String)token));
              }
 else               if (token instanceof Float) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.FLOAT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new FloatToken((Float)token));
              }
 else {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.OBJECT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new ObjectToken(token));
              }
            }
            _receivedTokens.get(identifier).clear();
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void fire() throws IllegalActionException {
  super.fire();
  boolean portTypeDefined=false;
synchronized (this) {
    if (_receivedTokens.size() > 0) {
      if (_receivedTokens.keySet().size() > 0) {
        for (        String identifier : _receivedTokens.keySet()) {
          TypedIOPort destinationPort=(TypedIOPort)this.getPort(identifier);
          if (destinationPort == null || !destinationPort.isOutput()) {
            _receivedTokens.remove(identifier);
          }
 else {
            if (destinationPort.getType() != null) {
              portTypeDefined=true;
            }
            for (            Object token : _receivedTokens.get(identifier)) {
              if (token instanceof Double) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.DOUBLE);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new DoubleToken((Double)token));
              }
 else               if (token instanceof Integer) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.INT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new IntToken((Integer)token));
              }
 else               if (token instanceof String) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.STRING);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new StringToken((String)token));
              }
 else               if (token instanceof Float) {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.FLOAT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new FloatToken((Float)token));
              }
 else {
                if (!portTypeDefined) {
                  destinationPort.setTypeEquals(BaseType.OBJECT);
                  portTypeDefined=true;
                }
                destinationPort.send(0,new ObjectToken(token));
              }
            }
            _receivedTokens.get(identifier).clear();
          }
        }
      }
    }
  }
}