Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerValues.resolveDeferredValue has incorrect cast #962

Open
chrylis opened this issue Jun 21, 2024 · 1 comment
Open

ServerValues.resolveDeferredValue has incorrect cast #962

chrylis opened this issue Jun 21, 2024 · 1 comment

Comments

@chrylis
Copy link

chrylis commented Jun 21, 2024

  • 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)
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants