fury icon indicating copy to clipboard operation
fury copied to clipboard

[Upgrade to Fury 0.5] class org.apache.fury.serializer.UnexistedClassSerializers$UnexistedSkipClass cannot be cast to class

Open cdxf opened this issue 1 year ago • 1 comments

Search before asking

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

Version

0.5.0

Component(s)

Java

Minimal reproduce step

I have the following code:

//Fury Configuration
    public static ThreadSafeFury fury = new ThreadLocalFury(classLoader -> {
        Fury f = Fury.builder()
                .requireClassRegistration(false)
                .withRefTracking(true)
                .withAsyncCompilation(true)
                .withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
                .withJdkClassSerializableCheck(false)
                .withLanguage(Language.JAVA).withClassLoader(classLoader).build();
        f.register(CircularFifoQueue.class);

// Function 
public T get(String key) {
            try {
                return (T) fury.deserialize(bytes);
            } catch (Exception ex) {
                logger.error("Error deserializing object", ex);
                return null;
            }
}
... later

        Queue<Long> result = get(...);

What did you expect to see?

Fury should throw Exception (which is what I am expecting when upgrading to new version and Fury failed to deserialize the byte[] from the old version) instead of silently deserialize the bytes into UnexistedClassSerializers$UnexistedSkipClass

What did you see instead?

It works fine in Fury 0.4.1, but since I upgraded to 0.5.0, my app throws the following errors:

java.lang.ClassCastException: class org.apache.fury.serializer.UnexistedClassSerializers$UnexistedSkipClass cannot be cast to class java.util.Queue (org.apache.fury.serializer.UnexistedClassSerializers$UnexistedSkipClass is in unnamed module of loader org.springframework.boot.loader.launch.LaunchedClassLoader @1d56ce6a; java.util.Queue is in module java.base of loader 'bootstrap')

Anything Else?

If it is expected behavior, where should I look at in the documentation. What should I do instead? Is there any configuration I can change to make it throw Exception instead of returning UnexistedSkipClass

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

cdxf avatar May 04 '24 22:05 cdxf

Hi @cdxf , thanks for reporting this issue. It seems that you use newer version of Fury to deserialize data from old version Fury. Fury read a class id for UnexistedSkipClass, so it throw such exception.

Fury registered UnexistedSkipClass https://github.com/apache/incubator-fury/blob/48361cb7b7c13e703f0d5e1a10d5d104c9cd78a2/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java#L349 This registered class id may be used by other class in older Fury, it's possible to read it as UnexistedSkipClass, which is the error you see. I can submit a PR to skip register UnexistedSkipClass, but if you use newer Fury to deserialize older Fury, you will still see other strange error. Currently we didn' provide binary compatibility. Such compatibility will be provided in the future, but not now. Could you try https://fury.apache.org/docs/guide/java_object_graph_guide#upgrade-fury to upgrade Fury?

chaokunyang avatar May 05 '24 04:05 chaokunyang