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

deserialize failed:After the class with the upstream system itself is serialized, the downstream system can not deserialize without the class object #1928

Open
shuyufang opened this issue Nov 5, 2024 · 2 comments
Labels
question Further information is requested

Comments

@shuyufang
Copy link

Question

public class FurySerializer implements Serializer {

/**
 * fury配置
 */
private static final ThreadSafeFury fury = new FuryBuilder().withLanguage(Language.JAVA)
    .withRefTracking(true)
    .requireClassRegistration(false)
    .withDeserializeNonexistentClass(true)
    .withMetaShare(true)
    .withAsyncCompilation(true)
    .withCompatibleMode(CompatibleMode.COMPATIBLE)
    .withScopedMetaShare(true)
    .withCodegen(true).buildThreadSafeFury();

@Override
public byte[] serialize(Object obj, Integer feature) throws SerializerException {
    try {
        return fury.serializeJavaObject(obj);
    } catch (Exception e) {
        logger.error("[FurySerializer.serialize] exception " + e.getMessage(), e);
        throw new SerializerException(e.toString(), e);
    }
}

@Override
public <T> T deserialize(byte[] bytes, Class<T> cls) throws SerializerException {
    try {
        return fury.deserializeJavaObject(bytes, cls);
    } catch (Exception e) {
        logger.error("[FurySerializer.deserialize] exception " + e.getMessage(), e);
        throw new SerializerException(e.toString(), e);
    }
}

public class FurySerializerTest {

private FurySerializer furySerializer = new FurySerializer();

@Test
public void test() {
    try {
        byte[] byteBuf = new byte[9000];
        // 20241029201856_0B5DEB3A16AD446626A7948A497B9008_84110 Y
        // 20240904171221_212BA390147466B59B7D1320A7820000_84110 F
        String file = "/home/admin/upload/20241029201856_0B5DEB3A16AD446626A7948A497B9008_84110";
        InputStream input = Files.newInputStream(new File(file).toPath());
        int read = IOUtils.read(input, byteBuf);
        System.out.println(read);
        furySerializer.deserialize(byteBuf, AsynMessageRequest.class);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Assert.assertTrue(true);
}

}

image

@shuyufang shuyufang added the question Further information is requested label Nov 5, 2024
@shuyufang shuyufang changed the title After the class with the upstream system itself is serialized, the downstream system can not deserialize without the class object deserialize failed:After the class with the upstream system itself is serialized, the downstream system can not deserialize without the class object Nov 5, 2024
@shuyufang
Copy link
Author

org.apache.fury fury-core 0.8.0

@zhaommmmomo
Copy link
Member

You can try serialize and deserialize method。For non-existent classes, the corresponding information will be saved in NonexistentClass.NonexistentMetaShared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants