kotlinx-io icon indicating copy to clipboard operation
kotlinx-io copied to clipboard

ChannelAsInput.readFully(ByteBuffer) throws IllegalArgumentException: Not enough bytes available (0) to read 128 bytes

Open rgoldberg opened this issue 5 years ago • 0 comments
trafficstars

In 0.1.16, ChannelAsInput.readFully(ByteBuffer) throws an IllegalArgumentException: Not enough bytes available (0) to read 128 bytes, when a similar call using a ByteArray instead of a ByteBuffer works fine.

e.g.:

fun test(sbc: SeekableByteChannel) {
	val LENGTH = 128
	sbc.position(sbc.size() - LENGTH)
	sbc.asInput().readFully(ByteBuffer.allocateDirect(LENGTH)) // throws exception
//	sbc.asInput().readFully(ByteArray(LENGTH), 0, LENGTH)      // substituting this line for the one above works without exception
}

Using:

kotlinx-io: 0.1.16 kotlin: 1.3.70 java: AdoptOpenJDK (build 13.0.2+8) gradle: 6.2.1 macOS: 10.15.3

rgoldberg avatar Mar 04 '20 07:03 rgoldberg