netty/netty — Issue #83: ChannelBuffer#array bug?
Author: ngocdaothanh
Created: 2011-11-25 05:17:47+00:00
State: open

The code below is in Scala.
Please see the last 2 lines.

Although the doc says that "array" returns the backing byte array of this buffer,
the returned array is useless if it can be anything.
The code below shows that its size is not the same as buffer.readableBytes.

Is this a bug?

```scala
import java.nio.charset.Charset
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.handler.codec.base64.{Base64, Base64Dialect}

val buffer = Base64.decode(ChannelBuffers.copiedBuffer("aGk=", Charset.forName("UTF-8")), Base64Dialect.URL_SAFE)

buffer.readableBytes // => 2: correct because "aGk=" is "hi" encoded in base 64
buffer.array // => Array(104, 105, 0): is this correct???
```