Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positive

オープン 初心者向け
#14,533 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
databases

調査の方向性

com.google.cloud.firestore.encoding.CustomClassMapper.java の convertBigDecimal から開始し、DocumentSnapshot.toObject(Class) がそこに到達する経路を追跡します。負の Firestore 浮動小数点値を BigDecimal フィールドにデシリアライズする処理を再現します。負号が保持され、既存の整数、BigDecimal、String の変換が引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Environment
  • Artifact: com.google.cloud:google-cloud-firestore (also used via com.google.firebase:firebase-admin)
  • Affected Versions: 3.21.1 through 3.48.0 (latest)
  • File: com.google.cloud.firestore.encoding.CustomClassMapper.java

Describe the Bug

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 :

private static BigDecimal convertBigDecimal(Object o, DeserializeContext.ErrorPath errorPath) {
    if (o instanceof Integer) {
        return BigDecimal.valueOf(((Integer) o).intValue());
    } else if (o instanceof Long) {
        return BigDecimal.valueOf(((Long) o).longValue());
    } else if (o instanceof Double) {
        return BigDecimal.valueOf(((Double) o).doubleValue()).abs(); // <--- Calls .abs()
    } else if (o instanceof BigDecimal) {
        return (BigDecimal) o;
    } else if (o instanceof String) {
        return new BigDecimal((String) o);
    } else {
        throw errorPath.deserializeError(
            "Failed to convert a value of type " + o.getClass().getName() + " to BigDecimal");
    }
}
主要言語
Java
スター
2.1k
フォーク
1.2k
平均マージ
2日 7時間
マージ済み PR(30日)
153

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-cloud-java のほかの issue

googleapis/google-cloud-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。