Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

ServerValues.resolveDeferredValue has incorrect cast

Open
#962 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
firebase, java
Domain
databases

Research direction

Start at ServerValues.resolveDeferredValue in ServerValues.java:44 and trace its callers through ServerValues.resolveDeferredValueSnapshot and Repo.setValue. Reproduce the failure through DatabaseReference.setValue using the documented map-shaped .sv increment value. Done means this input no longer fails with the reported ClassCastException, with behavior checked against the issue's reproduction steps.

Written by the indexing model from the issue text.

Description

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 firebase-database-client@google.com
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)
Dominant language
Java
Stars
620
Forks
305
Avg merge
3h 23m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-java

All issues in firebase/firebase-admin-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.