Neiko2002 opened a new issue, #1528:
URL: https://github.com/apache/incubator-fury/issues/1528

   ### 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.4.1
   OS: Windows
   JDK: 21
   
   ### Component(s)
   
   Java
   
   ### Minimal reproduce step
   
   public static void main(String[] args) throws Exception {
        Fury fury = Fury.builder().requireClassRegistration(false).build();
        try (OutputStream output = new 
BufferedOutputStream(Files.newOutputStream(Files.createTempFile(null, null)))) {
                fury.serialize(output, new BigObj());
        }
   }
        
   static public class BigObj {
        public byte[] b1 = new byte[Integer.MAX_VALUE/2];
        public byte[] b2 = new byte[Integer.MAX_VALUE/2];
   }
   
   ### What did you expect to see?
   
   I was hoping to get an file with 2147483646 bytes, all zero.
   
   ### What did you see instead?
   
   Exception in thread "main" java.lang.NegativeArraySizeException: -2147483510
        at io.fury.memory.MemoryBuffer.ensure(MemoryBuffer.java:1980)
        at 
io.fury.memory.MemoryBuffer.writePrimitiveArrayWithSizeEmbedded(MemoryBuffer.java:1946)
        at 
io.fury.serializer.ArraySerializers$ByteArraySerializer.write(ArraySerializers.java:290)
   
   ### Anything Else?
   
   I think when providing an OutputStream to the serialize method the 
intermediate MemoryBuffer should behave like the buffer inside the 
BufferedOutputStream. When the buffer is full it should flush its content to 
the underlying OutputStream in order to free up its bytes.
   
   
   ### Are you willing to submit a PR?
   
   - [ ] 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]

Reply via email to