157152688 opened a new issue, #1564: URL: https://github.com/apache/incubator-fury/issues/1564
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-fury/issues) and found no similar issues. ### Version Version: 0.5.0 (built from source) OS: macOS ### Component(s) Java ### Minimal reproduce step package alsc.ele.lpd.dispatch.matrix.service.tt; import alsc.ele.lpd.dispatch.matrix.service.dto.AssignDetailInfoLog; import alsc.ele.lpd.dispatch.matrix.service.dto.AssignType; import alsc.ele.lpd.dispatch.matrix.service.util.FuryUtils; import me.ele.lpd.dispatch.matrix.score.infra.config.CompressEnum; import me.ele.lpd.dispatch.matrix.score.infra.utils.CompressObjectUtils; import me.ele.lpd.dispatch.matrix.score.infra.utils.Lz4Util; import org.xerial.snappy.Snappy; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.file.Files; public class Test { public static void main(String[] args) throws IOException { // read read(); // write(); } public static void write() throws IOException { AssignDetailInfoLog assignDetailInfoLog = new AssignDetailInfoLog(); assignDetailInfoLog.setType(AssignType.DEFAULT); assignDetailInfoLog.setId("dsa"); byte[] data = FuryUtils.serialize(assignDetailInfoLog); saveToFile("test_file", data); } public static void read() throws IOException { // read byte[] data = readFileToBytes("test_file"); FuryUtils.zeroCopyDeserialize(data); } public static void saveToFile(String fileName, byte[] data) { try (FileOutputStream outputStream = new FileOutputStream(fileName)) { outputStream.write(data); // 写入byte[] System.out.println("Data has been written to " + fileName); } catch (IOException e) { e.printStackTrace(); } } public static byte[] readFileToBytes(String filePath) { try { return Files.readAllBytes(new File(filePath).toPath()); } catch (Exception e) { return null; } } } package alsc.ele.lpd.dispatch.matrix.service.dto; import lombok.Data; @Data public class AssignDetailInfoLog { String id; AssignType type; } package alsc.ele.lpd.dispatch.matrix.service.dto; public enum AssignType { DEFAULT; } package alsc.ele.lpd.dispatch.matrix.service.util; import org.apache.fury.Fury; import org.apache.fury.ThreadSafeFury; import org.apache.fury.config.CompatibleMode; import org.apache.fury.logging.LoggerFactory; import java.nio.ByteBuffer; public class FuryUtils { private static final ThreadSafeFury fury; public FuryUtils() { } public static <T> byte[] serialize(T t) { return fury.serialize(t); } public static Object zeroCopyDeserialize(byte[] byteBuffer) { return fury.deserialize(byteBuffer); } public static Object zeroCopyDeserialize(ByteBuffer byteBuffer) { return fury.deserialize(byteBuffer); } static { fury = Fury.builder().withRefTracking(true).requireClassRegistration(false).withCompatibleMode(CompatibleMode.COMPATIBLE).buildThreadSafeFury(); LoggerFactory.disableLogging(); } } ### What did you expect to see? deserialize ### What did you see instead? After deleting the AssignType file, an error occurred. Deserialize failed, read objects are: [AssignDetailInfoLog(id=dsa), null] at org.apache.fury.Fury.handleReadFailed(Fury.java:788) at org.apache.fury.Fury.deserialize(Fury.java:750) at org.apache.fury.Fury.deserialize(Fury.java:676) at org.apache.fury.ThreadLocalFury.deserialize(ThreadLocalFury.java:130) at alsc.ele.lpd.dispatch.matrix.service.util.FuryUtils.zeroCopyDeserialize(FuryUtils.java:21) at alsc.ele.lpd.dispatch.matrix.service.tt.Test.main(Test.java:30) Caused by: java.lang.IllegalStateException: Class alsc.ele.lpd.dispatch.matrix.service.dto.AssignType not found from classloaders [sun.misc.Launcher$AppClassLoader@18b4aac2, sun.misc.Launcher$AppClassLoader@18b4aac2] at org.apache.fury.resolver.ClassResolver.loadClass(ClassResolver.java:1688) at org.apache.fury.resolver.ClassResolver.loadBytesToClass(ClassResolver.java:1636) ### Anything Else? deserialize ### Are you willing to submit a PR? - [X] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
