You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java-firestore] CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive #14533
When deserializing a Firestore document containing a negative floating point number into a Java POJO field of type java.math.BigDecimal using DocumentSnapshot.toObject(Class<T>), the negative value is converted to a positive number.
Offending Code
In com.google.cloud.firestore.encoding.CustomClassMapper.java :
privatestaticBigDecimalconvertBigDecimal(Objecto, DeserializeContext.ErrorPatherrorPath) {
if (oinstanceofInteger) {
returnBigDecimal.valueOf(((Integer) o).intValue());
} elseif (oinstanceofLong) {
returnBigDecimal.valueOf(((Long) o).longValue());
} elseif (oinstanceofDouble) {
returnBigDecimal.valueOf(((Double) o).doubleValue()).abs(); // <--- Calls .abs()
} elseif (oinstanceofBigDecimal) {
return (BigDecimal) o;
} elseif (oinstanceofString) {
returnnewBigDecimal((String) o);
} else {
throwerrorPath.deserializeError(
"Failed to convert a value of type " + o.getClass().getName() + " to BigDecimal");
}
}
changed the title [-]CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive[/-][+][java-firestore] CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive[/+]on Sep 29, 2026
Activity
[-]CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive[/-][+][java-firestore] CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive[/+]