msgpack-java icon indicating copy to clipboard operation
msgpack-java copied to clipboard

Fixed UnpackerConfig.bufferSize to work

Open napo0703 opened this issue 3 years ago • 1 comments

This will Resolve #657

It limits internal buffer size when unpacking Array and Map. However, I think the default bufferSize of 8192 is too small. I changed the default buffer size to 100MiB following msgpack-python.

napo0703 avatar Jun 22 '22 15:06 napo0703

Buffer size limits now work, but some tests no longer pass. Should I change the Unpacker buffer size used for this test in the settings?

-        val unpacker = MessagePack.newDefaultUnpacker(new InputStreamBufferInput(new ByteArrayInputStream(out.toByteArray)))
+        val unpacker = new MessagePack.UnpackerConfig().withBufferSize(16 * 1024).newUnpacker(new InputStreamBufferInput(new ByteArrayInputStream(out.toByteArray)))

napo0703 avatar Jun 29 '22 15:06 napo0703

Upon re-reading the PR, I noticed some misunderstandings.

UnpackerConfig.bufferSize is used to control the internal buffer size, but it is not meant to limit the size of the uncompressed data. In order to prevent loading excessively large data into memory, we need to introduce another configuration.

I will close this pull request because it has become outdated. The requirement to limit the uncompressed data size and fail the Unpacker is still valid, but it should be addressed in a different context.

xerial avatar Sep 24 '23 04:09 xerial