Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

ServerValues.resolveDeferredValue has incorrect cast

未關閉
#962 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 4 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
firebase, java
領域
databases

研究方向

從 ServerValues.java:44 中的 ServerValues.resolveDeferredValue 開始,經由 ServerValues.resolveDeferredValueSnapshot 和 Repo.setValue 追蹤其呼叫者。使用文件中所述的 map 形式 .sv 增量值,透過 DatabaseReference.setValue 重現該失敗。當此輸入不再因回報的 ClassCastException 而失敗,且已根據 issue 的重現步驟檢查行為時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

api: database
  • Operating System version: Gentoo Linux
  • Firebase SDK version: 9.3.0
  • Library version: 9.3.0 (but the bug goes back to at least 8.1.0)
  • Firebase Product: RTDB

As ServerValue.increment is still not supported by this SDK 4 years after its introduction, I tried implementing it manually. This triggers a ClassCastException inside the SDK due to a bad assumption that the value of the .sv key is always a String.

Steps to reproduce:
  1. Create the data structure for ServerValue.increment as described in documentation (such as the REST documentation):
{
  ".sv": {
    "increment": delta
  }
}
  1. Call setValue using this data structure.
Relevant Code:
var node = databaseNode();
node.setValue(Map.of(".sv", Map.of("increment", delta)), callback);
Error:
2024-06-21T19:58:12,008Z [firebase-database-worker] ERROR c.g.firebase.database.core.RunLoop - Uncaught exception in Firebase Database runloop (9.3.0). Please report to [email protected]
java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')
	at com.google.firebase.database.core.ServerValues.resolveDeferredValue(ServerValues.java:44)
	at com.google.firebase.database.core.ServerValues.resolveDeferredValueSnapshot(ServerValues.java:80)
	at com.google.firebase.database.core.Repo.setValue(Repo.java:376)
	at com.google.firebase.database.DatabaseReference$1.run(DatabaseReference.java:305)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
主要語言
Java
星號
620
分支
306
平均合併
4 天 7 小時
30 天內合併 PR
13

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

firebase/firebase-admin-java 的其他 Issue

查看 firebase/firebase-admin-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。