Skip to content

[Java] LambdaSerializer cannot be initialized when Language is XLANG. #3112

@JackyAnn

Description

@JackyAnn

Search before asking

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

Version

implementation 'org.apache.fory:fory-core:0.14.1'

code:

public class Main {
    public static void main(String[] args) {
        BaseFory fory = Fory.builder()
                .withLanguage(Language.XLANG)
                .requireClassRegistration(true)
                // replace `build` with `buildThreadSafeFory` for Thread-Safe Usage
                .build();
        fory.ensureSerializersCompiled();
    }
}

error:
Exception in thread "main" java.lang.NullPointerException
at org.apache.fory.util.Preconditions.checkNotNull(Preconditions.java:26)
at org.apache.fory.resolver.XtypeResolver.setSerializerIfAbsent(XtypeResolver.java:725)
at org.apache.fory.builder.SerializedLambdaForyCodec_0.(SerializedLambdaForyCodec_0.java:33)
at org.apache.fory.serializer.Serializers.createSerializer(Serializers.java:142)
at org.apache.fory.serializer.Serializers.newSerializer(Serializers.java:112)
at org.apache.fory.serializer.LambdaSerializer.getDataSerializer(LambdaSerializer.java:157)
at org.apache.fory.serializer.LambdaSerializer.(LambdaSerializer.java:102)
at org.apache.fory.serializer.Serializers.createSerializer(Serializers.java:142)
at org.apache.fory.serializer.Serializers.newSerializer(Serializers.java:112)
at org.apache.fory.resolver.ClassResolver.ensureSerializersCompiled(ClassResolver.java:1911)
at org.apache.fory.Fory.ensureSerializersCompiled(Fory.java:1609)

same issue in quarkus-fory
quarkiverse/quarkus-fory#134

Component(s)

Java

Minimal reproduce step

code:

public class Main {
    public static void main(String[] args) {
        BaseFory fory = Fory.builder()
                .withLanguage(Language.XLANG)
                .requireClassRegistration(true)
                // replace `build` with `buildThreadSafeFory` for Thread-Safe Usage
                .build();
        fory.ensureSerializersCompiled();
    }
}

What did you expect to see?

no exception

What did you see instead?

The given exception.

Anything Else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions