Program: 134935
Project: 134935
Buggy source:
/** 
 * Generate a random collection of keys. The size of the collection can be random or fixed. If it is random then the exact parameter must be false; in that case the number of elements returned is limited by size (inclusive) The number of elements in the collection is fixed if the exact parameter is true; in that case the number of elements returned is specified in size. If the size is random, the returned collection can be empty. If common is not null, each generated key must also be present in common. For this to work, the size of common is an upper limit for the size of the  returned collection.
 * @param size The upper limit of the number of elements in the collection or the number of elements in the returned collection depending on the value of the exact parameter 
 * @param exact If true the size of the returned collection is equal tosize otherwise size is the maximum limit
 * @param minValue The minimum allowed value of the keys in the collection (inclusive)
 * @param maxValue The maximum allowed value of the keys in the collection (inclusive)
 * @param common A collection of keys They key in the returned collection must be present in common too If common is null the keys are generated without constraints 
 * @return A posible empty collection of keys
 */
public static Collection<Integer> generateKeys(int size,boolean exact,int minValue,int maxValue,Collection<Integer> common){
  if (size <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (minValue < 0 && maxValue < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (minValue >= maxValue) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (exact && size > common.size()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int desiredLength=0;
  Random rnd=new Random(System.currentTimeMillis());
  if (!exact) {
    while (desiredLength == 0) {
      desiredLength=rnd.nextInt(size + 1);
    }
  }
 else {
    desiredLength=size;
  }
  if (maxValue - minValue + 1 < desiredLength) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Vector<Integer> v=new Vector<Integer>(desiredLength);
  if (desiredLength == common.size()) {
    for (    Integer key : common) {
      v.add(key);
    }
  }
 else {
    Integer key=-1;
    while (v.size() < desiredLength) {
      while (key < minValue || key > maxValue) {
        key=rnd.nextInt(maxValue + 1);
        if ((common != null && !common.contains(key)) || v.contains(key)) {
          key=-1;
        }
      }
      v.add(key);
      key=-1;
    }
  }
  return v;
}

Fixed version (ground truth):
/** 
 * Generate a random collection of keys. The size of the collection can be random or fixed. If it is random then the exact parameter must be false; in that case the number of elements returned is limited by size (inclusive) The number of elements in the collection is fixed if the exact parameter is true; in that case the number of elements returned is specified in size. If the size is random, the returned collection can be empty. If common is not null, each generated key must also be present in common. For this to work, the size of common is an upper limit for the size of the  returned collection.
 * @param size The upper limit of the number of elements in the collection or the number of elements in the returned collection depending on the value of the exact parameter 
 * @param exact If true the size of the returned collection is equal tosize otherwise size is the maximum limit
 * @param minValue The minimum allowed value of the keys in the collection (inclusive)
 * @param maxValue The maximum allowed value of the keys in the collection (inclusive)
 * @param common A collection of keys They key in the returned collection must be present in common too If common is null the keys are generated without constraints 
 * @return A posible empty collection of keys
 */
public static Collection<Integer> generateKeys(int size,boolean exact,int minValue,int maxValue,Collection<Integer> common){
  if (size <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (minValue < 0 && maxValue < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (minValue >= maxValue) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (exact && size > common.size()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int desiredLength=0;
  Random rnd=new Random(System.currentTimeMillis());
  if (!exact) {
    while (desiredLength == 0 || (maxValue - minValue + 1 < desiredLength)) {
      desiredLength=rnd.nextInt(size + 1);
    }
  }
 else {
    desiredLength=size;
  }
  Vector<Integer> v=new Vector<Integer>(desiredLength);
  if (desiredLength == common.size()) {
    for (    Integer key : common) {
      v.add(key);
    }
  }
 else {
    Integer key=-1;
    while (v.size() < desiredLength) {
      while (key < minValue || key > maxValue) {
        key=rnd.nextInt(maxValue + 1);
        if ((common != null && !common.contains(key)) || v.contains(key)) {
          key=-1;
        }
      }
      v.add(key);
      key=-1;
    }
  }
  return v;
}