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

java.lang.ClassCastException: class scala.collection.immutable.HashMap cannot be cast to class scala.collection.Factory #2021

Open
1 of 2 tasks
davidnadeau opened this issue Jan 23, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@davidnadeau
Copy link

davidnadeau commented Jan 23, 2025

Search before asking

  • I had searched in the issues and found no similar issues.

Version

0.9.0

Component(s)

Other, Java

Minimal reproduce step

I am trying to deserialize into the scala type: Map[String, String].

What did you expect to see?

No error

What did you see instead?

Failed to deserialize key:
* binary data *
due to exception: java.lang.ClassCastException: class scala.collection.immutable.HashMap cannot be cast to class scala.collection.Factory (scala.collection.immutable.HashMap and scala.collection.Factory are in unnamed module of loader 'app')"

Anything Else?

This issue did not appear to be present in java jdk 17, but only when we upgraded to jdk 21. There are no errors with jdk 21 and fury 0.7.0.

In 0.9.0 i've started using the new Scala serializers

import org.apache.fury.serializer.scala.ScalaSerializers
ScalaSerializers.registerSerializers(fury)

I think there is an issue with the scala serializers.

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@davidnadeau davidnadeau added the bug Something isn't working label Jan 23, 2025
@chaokunyang
Copy link
Collaborator

@davidnadeau could you provide reproduction code?

@davidnadeau
Copy link
Author

davidnadeau commented Jan 24, 2025

Hi @chaokunyang my fury config looks like:

  val fury = Fury
    .builder()
    .withScalaOptimizationEnabled(true)
    .requireClassRegistration(false)
    .withRefTracking(false)
    .buildThreadSafeFuryPool(Runtime.getRuntime.availableProcessors() * 2, Runtime.getRuntime.availableProcessors() * 2)

  ScalaSerializers.registerSerializers(fury)

@davidnadeau
Copy link
Author

I am working to provide more details. I want to test 3 scenarios:

  1. jdk 21 fury 0.9.0 fury_core dep
  2. jdk 21 fury 0.9.0 fury_scala dep (no scala serializers)
  3. jdk 21 fury 0.9.0 fury_scala dep + scala serializers

I will report back my findings. And try to provide a more detailed reproduction code, however I have a suspicion that it may be a thread race condition. Alongside the failures to deserialize I also saw other errors.

java.lang.ArrayIndexOutOfBoundsException

and

ERROR  ThreadPoolFury:84 [finagle/netty4-1-49] - null
java.lang.NullPointerException

@chaokunyang
Copy link
Collaborator

Hi @davidnadeau , I tested HashMap with jdk 21, it still works:

val v = scala.collection.immutable.HashMap("k1" -> "v1", "k2" -> "v2")
fury.deserialize(fury.serialize(v)) shouldEqual v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants