Program: 47737
Project: 47737
Buggy source:
/** 
 * Perform Kettle type conversions for the Mongo leaf field value.
 * @param fieldValue the leaf value from the Mongo structure
 * @return an Object of the appropriate Kettle type
 * @throws KettleException if a problem occurs
 */
protected Object getKettleValue(Object fieldValue) throws KettleException {
switch (m_tempValueMeta.getType()) {
case ValueMetaInterface.TYPE_BIGNUMBER:
    if (fieldValue instanceof Number) {
      fieldValue=BigDecimal.valueOf(((Number)fieldValue).doubleValue());
    }
 else     if (fieldValue instanceof Date) {
      fieldValue=new BigDecimal(((Date)fieldValue).getTime());
    }
 else {
      fieldValue=new BigDecimal(fieldValue.toString());
    }
  return m_tempValueMeta.getBigNumber(fieldValue);
case ValueMetaInterface.TYPE_BINARY:
if (fieldValue instanceof Binary) {
  fieldValue=((Binary)fieldValue).getData();
}
 else {
  fieldValue=fieldValue.toString().getBytes();
}
return m_tempValueMeta.getBinary(fieldValue);
case ValueMetaInterface.TYPE_BOOLEAN:
if (fieldValue instanceof Number) {
fieldValue=new Boolean(((Number)fieldValue).intValue() != 0);
}
 else if (fieldValue instanceof Date) {
fieldValue=new Boolean(((Date)fieldValue).getTime() != 0);
}
 else {
fieldValue=new Boolean(fieldValue.toString().equalsIgnoreCase("String_Node_Str") || fieldValue.toString().equalsIgnoreCase("String_Node_Str") || fieldValue.toString().equalsIgnoreCase("String_Node_Str"));
}
return m_tempValueMeta.getBoolean(fieldValue);
case ValueMetaInterface.TYPE_DATE:
if (fieldValue instanceof Number) {
fieldValue=new Date(((Number)fieldValue).longValue());
}
 else {
throw new KettleException(BaseMessages.getString(MongoDbInputMeta.PKG,"String_Node_Str",fieldValue.toString()));
}
return m_tempValueMeta.getDate(fieldValue);
case ValueMetaInterface.TYPE_INTEGER:
if (fieldValue instanceof Number) {
fieldValue=new Long(((Number)fieldValue).intValue());
}
 else if (fieldValue instanceof Binary) {
byte[] b=((Binary)fieldValue).getData();
String s=new String(b);
fieldValue=new Integer(s);
}
 else {
fieldValue=new Integer(fieldValue.toString());
}
return m_tempValueMeta.getInteger(fieldValue);
case ValueMetaInterface.TYPE_NUMBER:
if (fieldValue instanceof Number) {
fieldValue=new Double(((Number)fieldValue).doubleValue());
}
 else if (fieldValue instanceof Binary) {
byte[] b=((Binary)fieldValue).getData();
String s=new String(b);
fieldValue=new Double(s);
}
 else {
fieldValue=new Double(fieldValue.toString());
}
return m_tempValueMeta.getNumber(fieldValue);
case ValueMetaInterface.TYPE_STRING:
return m_tempValueMeta.getString(fieldValue);
default :
return null;
}
}

Fixed version (ground truth):
/** 
 * Perform Kettle type conversions for the Mongo leaf field value.
 * @param fieldValue the leaf value from the Mongo structure
 * @return an Object of the appropriate Kettle type
 * @throws KettleException if a problem occurs
 */
protected Object getKettleValue(Object fieldValue) throws KettleException {
switch (m_tempValueMeta.getType()) {
case ValueMetaInterface.TYPE_BIGNUMBER:
    if (fieldValue instanceof Number) {
      fieldValue=BigDecimal.valueOf(((Number)fieldValue).doubleValue());
    }
 else     if (fieldValue instanceof Date) {
      fieldValue=new BigDecimal(((Date)fieldValue).getTime());
    }
 else {
      fieldValue=new BigDecimal(fieldValue.toString());
    }
  return m_tempValueMeta.getBigNumber(fieldValue);
case ValueMetaInterface.TYPE_BINARY:
if (fieldValue instanceof Binary) {
  fieldValue=((Binary)fieldValue).getData();
}
 else {
  fieldValue=fieldValue.toString().getBytes();
}
return m_tempValueMeta.getBinary(fieldValue);
case ValueMetaInterface.TYPE_BOOLEAN:
if (fieldValue instanceof Number) {
fieldValue=new Boolean(((Number)fieldValue).intValue() != 0);
}
 else if (fieldValue instanceof Date) {
fieldValue=new Boolean(((Date)fieldValue).getTime() != 0);
}
 else {
fieldValue=new Boolean(fieldValue.toString().equalsIgnoreCase("String_Node_Str") || fieldValue.toString().equalsIgnoreCase("String_Node_Str") || fieldValue.toString().equalsIgnoreCase("String_Node_Str"));
}
return m_tempValueMeta.getBoolean(fieldValue);
case ValueMetaInterface.TYPE_DATE:
if (fieldValue instanceof Number) {
fieldValue=new Date(((Number)fieldValue).longValue());
}
 else if (fieldValue instanceof Date) {
}
 else {
throw new KettleException(BaseMessages.getString(MongoDbInputMeta.PKG,"String_Node_Str",fieldValue.toString()));
}
return m_tempValueMeta.getDate(fieldValue);
case ValueMetaInterface.TYPE_INTEGER:
if (fieldValue instanceof Number) {
fieldValue=new Long(((Number)fieldValue).intValue());
}
 else if (fieldValue instanceof Binary) {
byte[] b=((Binary)fieldValue).getData();
String s=new String(b);
fieldValue=new Integer(s);
}
 else {
fieldValue=new Integer(fieldValue.toString());
}
return m_tempValueMeta.getInteger(fieldValue);
case ValueMetaInterface.TYPE_NUMBER:
if (fieldValue instanceof Number) {
fieldValue=new Double(((Number)fieldValue).doubleValue());
}
 else if (fieldValue instanceof Binary) {
byte[] b=((Binary)fieldValue).getData();
String s=new String(b);
fieldValue=new Double(s);
}
 else {
fieldValue=new Double(fieldValue.toString());
}
return m_tempValueMeta.getNumber(fieldValue);
case ValueMetaInterface.TYPE_STRING:
return m_tempValueMeta.getString(fieldValue);
default :
return null;
}
}