Program: 47758
Project: 47758
Buggy source:
/** 
 * Encode a key value (string) to an array of bytes. Useful for  encoding values entered by the user through the UI for the column filter editor
 * @param keyValue the key value (string) to encode
 * @param keyType the type of the key to encode
 * @return the key encoded as an array of bytes
 * @throws KettleException if something goes wrong
 */
public static byte[] encodeKeyValue(String keyValue,Mapping.KeyType keyType) throws KettleException {
  if (keyType == Mapping.KeyType.STRING) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes("String_Node_Str");
    }
 else {
      return Bytes.toBytes(keyValue);
    }
  }
  if (keyType == Mapping.KeyType.UNSIGNED_LONG || keyType == Mapping.KeyType.UNSIGNED_DATE) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0L);
    }
 else {
      return Bytes.toBytes(Long.parseLong(keyValue));
    }
  }
  if (keyType == Mapping.KeyType.UNSIGNED_INTEGER) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0);
    }
 else {
      return Bytes.toBytes(Integer.parseInt(keyValue));
    }
  }
  if (keyType == Mapping.KeyType.INTEGER) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0);
    }
 else {
      int bound=Integer.parseInt(keyValue);
      bound^=(1 << 31);
      return Bytes.toBytes(bound);
    }
  }
  if (keyType == Mapping.KeyType.LONG || keyType == Mapping.KeyType.DATE) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0L);
    }
 else {
      long bound=Long.parseLong(keyValue);
      bound^=(1L << 63);
      return Bytes.toBytes(bound);
    }
  }
  throw new KettleException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Encode a key value (string) to an array of bytes. Useful for  encoding values entered by the user through the UI for the column filter editor
 * @param keyValue the key value (string) to encode
 * @param keyType the type of the key to encode
 * @return the key encoded as an array of bytes
 * @throws KettleException if something goes wrong
 */
public static byte[] encodeKeyValue(String keyValue,Mapping.KeyType keyType) throws KettleException {
  if (keyType == Mapping.KeyType.STRING) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes("String_Node_Str");
    }
 else {
      return Bytes.toBytes(keyValue);
    }
  }
  if (keyType == Mapping.KeyType.UNSIGNED_LONG || keyType == Mapping.KeyType.UNSIGNED_DATE) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0L);
    }
 else {
      if (keyType == Mapping.KeyType.UNSIGNED_DATE) {
        throw new KettleException("String_Node_Str" + "String_Node_Str");
      }
      return Bytes.toBytes(Long.parseLong(keyValue));
    }
  }
  if (keyType == Mapping.KeyType.UNSIGNED_INTEGER) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0);
    }
 else {
      return Bytes.toBytes(Integer.parseInt(keyValue));
    }
  }
  if (keyType == Mapping.KeyType.INTEGER) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0);
    }
 else {
      int bound=Integer.parseInt(keyValue);
      bound^=(1 << 31);
      return Bytes.toBytes(bound);
    }
  }
  if (keyType == Mapping.KeyType.LONG || keyType == Mapping.KeyType.DATE) {
    if (Const.isEmpty(keyValue)) {
      return Bytes.toBytes(0L);
    }
 else {
      if (keyType == Mapping.KeyType.DATE) {
        throw new KettleException("String_Node_Str" + "String_Node_Str");
      }
      long bound=Long.parseLong(keyValue);
      bound^=(1L << 63);
      return Bytes.toBytes(bound);
    }
  }
  throw new KettleException("String_Node_Str");
}