Program: 186088
Project: 186088
Buggy source:
/** 
 * Trim an existing list so that it will contain only the specified range of elements specified. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on. <p> For example LTRIM foobar 0 2 will modify the list stored at foobar key so that only the first three elements of the list will remain. <p> start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on. <p> Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is left as value. If end over the end of the list Redis will threat it just like the last element of the list. <p> Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example: <p>  {@code lpush("mylist", "someelement"); ltrim("mylist", 0, 99); * }<p> The above two commands will push elements in the list taking care that the list will not grow without limits. This is very useful when using Redis to store logs for example. It is important to note that when used in this way LTRIM is an O(1) operation because in the average case just one element is removed from the tail of the list. <p>
 * @param key
 * @param start
 * @param end
 * @return Status code reply
 */
public String ltrim(final byte[] key,final int start,final int end){
  ByteBuffer wrappedKey=wrap(key);
  List<ByteBuffer> elements=new LinkedList<ByteBuffer>(this.blockingMultimap.elements(wrappedKey));
  int calculatedStart=RangeUtils.calculateStart(start,elements.size());
  int calculatedEnd=RangeUtils.calculateEnd(end,elements.size());
  try {
    List<ByteBuffer> sublist=elements.subList(calculatedStart,calculatedEnd);
    this.blockingMultimap.replaceValues(wrappedKey,sublist);
  }
 catch (  IndexOutOfBoundsException e) {
    return KO;
  }
catch (  IllegalArgumentException e) {
    return KO;
  }
  return OK;
}

Fixed version (ground truth):
/** 
 * Trim an existing list so that it will contain only the specified range of elements specified. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on. <p> For example LTRIM foobar 0 2 will modify the list stored at foobar key so that only the first three elements of the list will remain. <p> start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on. <p> Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is left as value. If end over the end of the list Redis will threat it just like the last element of the list. <p> Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example: <p>  {@code lpush("mylist", "someelement"); ltrim("mylist", 0, 99); * }<p> The above two commands will push elements in the list taking care that the list will not grow without limits. This is very useful when using Redis to store logs for example. It is important to note that when used in this way LTRIM is an O(1) operation because in the average case just one element is removed from the tail of the list. <p>
 * @param key
 * @param start
 * @param end
 * @return Status code reply
 */
public String ltrim(final byte[] key,final long start,final long end){
  ByteBuffer wrappedKey=wrap(key);
  List<ByteBuffer> elements=new LinkedList<ByteBuffer>(this.blockingMultimap.elements(wrappedKey));
  int calculatedStart=RangeUtils.calculateStart((int)start,elements.size());
  int calculatedEnd=RangeUtils.calculateEnd((int)end,elements.size());
  try {
    List<ByteBuffer> sublist=elements.subList(calculatedStart,calculatedEnd);
    this.blockingMultimap.replaceValues(wrappedKey,sublist);
  }
 catch (  IndexOutOfBoundsException e) {
    return KO;
  }
catch (  IllegalArgumentException e) {
    return KO;
  }
  return OK;
}