eclipse-ee4j / eclipse-ee4j/tyrus
Issues with binary decoder message Decoder.Binary<T>
- Dominant language
- Java
- Stars
- 128
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Hi, i am having trouble with the receiving end of the transfer of binary messages.
My encoder looks like this:
```
public class MessageEncoder implements Encoder.Binary {
@Override
public ByteBuffer encode(Message message) throws EncodeException {
System.out.println("Encoding "+message.getMsg().length);
byte[] toSend = message.getMsg();
ByteBuffer buff = ByteBuffer.allocate(toSend.length);
buff.put(toSend);
return buff;
}
@Override
public void init(EndpointConfig endpointConfig) {
}
@Override
public void destroy() {
}
}
```
While my Decoder looks like this
```
public class MessageDecoder implements Decoder.Binary{
@Override
public Message decode(ByteBuffer byteBuffer) throws DecodeException {
byte[] arr = byteBuffer.array();
System.out.println("Length "+arr.length);
return new Message(arr);
}
@Override
public boolean willDecode(ByteBuffer byteBuffer) {
return byteBuffer != null;
}
@Override
public void init(EndpointConfig endpointConfig) {
}
@Override
public void destroy() {
}
}
```
The output of the encoder is always `'Encoding X'` where X is the actual number of bytes that are encoded. While in the Decoder the output is always `'Length 0'` meaning the ByteBuffer parameter was empty on arrival. Is this a known bug or am i doing something wrong ?
Contributor guide
Assessment
This issue has not been assessed yet.