apigee / trireme

Embed Node.js inside a Java Virtual Machine
Other
479 stars 48 forks source link

Fix Buffer.getBuffer() when Buffer has an offset set for its underlying array #182

Closed AdamMagaluk closed 6 years ago

AdamMagaluk commented 6 years ago

ByteBuffer.wrap() was not previously setting the offset correctly Buffer was setting the position for the ByteBuffer assuming it meant offset.

Because ByteBuffer does not support setting the offset "Its backing array will be the given array, and its array offset will be zero.". Because of this we create an array copy of the usable array in Buffer and pass that to ByteBuffer.wrap. This only applies to caes where an offset is set to avoid unnecessary copies of the array.

This causes an error #181 for zlib compression when the Buffer comes from the HttpParser since the body is just an offset of the underlying full http message returned.

AdamMagaluk commented 6 years ago

@gbrail Made the change we talked about. Also all tests passing now with the DNS test fix.