Program: 8726
Project: 8726
Buggy source:
/** 
 * Get a byte array encoding the buckets of this cell in the Cube. For internal use only.
 */
public byte[] toKey(IdService idService) throws IOException {
  List<Dimension<?>> dimensions=cube.getDimensions();
  boolean sawOnlyWildcardsSoFar=true;
  List<byte[]> reversedKeyElems=Lists.newArrayListWithCapacity(dimensions.size());
  for (int i=dimensions.size() - 1; i >= 0; i--) {
    Dimension<?> dimension=dimensions.get(i);
    BucketTypeAndBucket bucketAndCoord=buckets.get(dimension);
    int thisDimBucketLen=dimension.getNumFieldBytes();
    int thisDimBucketTypeLen=dimension.getBucketPrefixSize();
    if (bucketAndCoord == BucketTypeAndBucket.WILDCARD || bucketAndCoord == null) {
      if (sawOnlyWildcardsSoFar) {
        continue;
      }
      reversedKeyElems.add(new byte[thisDimBucketTypeLen + thisDimBucketLen]);
      reversedKeyElems.add(WILDCARD_FIELD);
    }
 else {
      sawOnlyWildcardsSoFar=false;
      byte[] elem;
      if (idService == null || !dimension.getDoIdSubstitution()) {
        elem=bucketAndCoord.bucket;
      }
 else {
        int dimensionNum=cube.getDimensions().indexOf(dimension);
        elem=idService.getId(dimensionNum,bucketAndCoord.bucket,dimension.getNumFieldBytes());
      }
      if (elem.length != thisDimBucketLen) {
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + dimension + "String_Node_Str"+ dimension.getNumFieldBytes()+ "String_Node_Str"+ bucketAndCoord.bucket.length);
      }
      byte[] bucketTypeId=bucketAndCoord.bucketType.getUniqueId();
      if (bucketTypeId.length != thisDimBucketTypeLen) {
        throw new RuntimeException("String_Node_Str" + dimension + "String_Node_Str"+ dimension.getBucketPrefixSize()+ "String_Node_Str"+ Arrays.toString(bucketTypeId)+ "String_Node_Str"+ bucketTypeId.length);
      }
      reversedKeyElems.add(bucketAndCoord.bucket);
      reversedKeyElems.add(bucketTypeId);
      reversedKeyElems.add(NON_WILDCARD_FIELD);
    }
  }
  List<byte[]> keyElemsInOrder=Lists.reverse(reversedKeyElems);
  int totalKeySize=0;
  for (  byte[] keyElement : keyElemsInOrder) {
    totalKeySize+=keyElement.length;
  }
  ByteBuffer bb=ByteBuffer.allocate(totalKeySize);
  for (  byte[] keyElement : keyElemsInOrder) {
    bb.put(keyElement);
  }
  if (bb.remaining() != 0) {
    throw new AssertionError("String_Node_Str" + bb.remaining() + "String_Node_Str");
  }
  return bb.array();
}

Fixed version (ground truth):
/** 
 * Get a byte array encoding the buckets of this cell in the Cube. For internal use only.
 */
public byte[] toKey(IdService idService) throws IOException {
  List<Dimension<?>> dimensions=cube.getDimensions();
  boolean sawOnlyWildcardsSoFar=true;
  List<byte[]> reversedKeyElems=Lists.newArrayListWithCapacity(dimensions.size());
  for (int i=dimensions.size() - 1; i >= 0; i--) {
    Dimension<?> dimension=dimensions.get(i);
    BucketTypeAndBucket bucketAndCoord=buckets.get(dimension);
    int thisDimBucketLen=dimension.getNumFieldBytes();
    int thisDimBucketTypeLen=dimension.getBucketPrefixSize();
    if (bucketAndCoord == BucketTypeAndBucket.WILDCARD || bucketAndCoord == null) {
      if (sawOnlyWildcardsSoFar) {
        continue;
      }
      reversedKeyElems.add(new byte[thisDimBucketTypeLen + thisDimBucketLen]);
      reversedKeyElems.add(WILDCARD_FIELD);
    }
 else {
      sawOnlyWildcardsSoFar=false;
      byte[] elem;
      if (idService == null || !dimension.getDoIdSubstitution()) {
        elem=bucketAndCoord.bucket;
      }
 else {
        int dimensionNum=cube.getDimensions().indexOf(dimension);
        elem=idService.getId(dimensionNum,bucketAndCoord.bucket,dimension.getNumFieldBytes());
      }
      if (elem.length != thisDimBucketLen) {
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + dimension + "String_Node_Str"+ dimension.getNumFieldBytes()+ "String_Node_Str"+ bucketAndCoord.bucket.length);
      }
      byte[] bucketTypeId=bucketAndCoord.bucketType.getUniqueId();
      if (bucketTypeId.length != thisDimBucketTypeLen) {
        throw new RuntimeException("String_Node_Str" + dimension + "String_Node_Str"+ dimension.getBucketPrefixSize()+ "String_Node_Str"+ Arrays.toString(bucketTypeId)+ "String_Node_Str"+ bucketTypeId.length);
      }
      reversedKeyElems.add(elem);
      reversedKeyElems.add(bucketTypeId);
      reversedKeyElems.add(NON_WILDCARD_FIELD);
    }
  }
  List<byte[]> keyElemsInOrder=Lists.reverse(reversedKeyElems);
  int totalKeySize=0;
  for (  byte[] keyElement : keyElemsInOrder) {
    totalKeySize+=keyElement.length;
  }
  ByteBuffer bb=ByteBuffer.allocate(totalKeySize);
  for (  byte[] keyElement : keyElemsInOrder) {
    bb.put(keyElement);
  }
  if (bb.remaining() != 0) {
    throw new AssertionError("String_Node_Str" + bb.remaining() + "String_Node_Str");
  }
  return bb.array();
}