philippemarcelino commented on issue #2062: URL: https://github.com/apache/fury/issues/2062#issuecomment-2710373255
> [@philippemarcelino](https://github.com/philippemarcelino) Have you tried with 0.11.0-SNAPSHOT? I did not! I gave it a try this morning, with mixed results (mostly positive). I've tested with an instance of a rather complex class. Same results were observed with the following super simple class: ``` public class CustomClass implements Serializable { Map<String, Object> values = new LinkedHashMap<>(); public Map<String, Object> getValues() { return this.values; } } ``` Here are my test results. ## With codegen=false It seems to just work now :) ## With codegen=true object is an instance of a custom class CustomClass. CustomClass.values is a LinkedHashMap<String, Object> so it's easier to put a null value at some desired index/position CustomClass.values is empty at the start of each code example Since I use codegen, the JVM is restarted before each test just in case. Of course if the generated classes are cached somehow, this is a moot point... ### 1. Single entry #### 1.1 Non null value Works ok #### 1.2 Null value ``` // Throws exception: // readerIndex(192) + length(1) exceeds size(192): org.apache.fury.memory.MemoryBuffer$BoundChecker@15d50d64 object.getValues().put("86rbsj6si", null); fury.deserialize(fury.serialize(object)); ``` ### 2. Multiple entries #### 2.1 No null values Works ok. #### 2.2 Null values Null value added last ``` // Throws exception Cannot invoke "Object.getClass()" because "<local7>" is null object.getValues().put("0q20z6qfk", "Some string value"); object.getValues().put("1mws7xdj5", 1741046400000L); object.getValues().put("4a0yvgjjw", Map.of("value", 1.0, "currencyCode", "EUR")); object.getValues().put("86rbsj6si", null); fury.deserialize(fury.serialize(object)); ``` Null value added not first, not last ``` // Same, throws exception: Cannot invoke "Object.getClass()" because "<local7>" is null object.getValues().put("0q20z6qfk", "Some string value"); object.getValues().put("1mws7xdj5", 1741046400000L); object.getValues().put("86rbsj6si", null); object.getValues().put("4a0yvgjjw", Map.of("value", 1.0, "currencyCode", "EUR")); fury.deserialize(fury.serialize(object)); ``` Weirdest test case, null value added first: ``` // Works ok! object.getValues().put("86rbsj6si", null); object.getValues().put("0q20z6qfk", "Some string value"); object.getValues().put("1mws7xdj5", 1741046400000L); object.getValues().put("4a0yvgjjw", Map.of("value", 1.0, "currencyCode", "EUR")); fury.deserialize(fury.serialize(object)); ``` Just for the sake of completion, I've also tested with one additional nested level ``` // Expected this to work (first amount map entry has a null value), and indeed, it works :) object.getValues().put("0q20z6qfk", "Some string value"); object.getValues().put("1mws7xdj5", 1741046400000L); Map<String, Object> amount = new LinkedHashMap<>(); amount.put("value", null); amount.put("counterValue", 1.0); amount.put("currencyCode", "EUR"); object.getValues().put("4a0yvgjjw", amount); ``` ``` // Expected this to fail (last amount map entry has a null value), but it works?!... object.getValues().put("0q20z6qfk", "Some string value"); object.getValues().put("1mws7xdj5", 1741046400000L); Map<String, Object> amount = new LinkedHashMap<>(); amount.put("counterValue", 1.0); amount.put("currencyCode", "EUR"); amount.put("value", null); object.getValues().put("4a0yvgjjw", amount); ``` So, with codegen, sometimes it works, sometimes it fails with BoundChecker exception and sometimes it fails with a NPE within some generated code... Not sure how you can make sense of this, but I ran those tests multiple times with consistent results on my dev machine (win11, OpenJDK 17.0.10_7 from Adoptium) -- 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]
