-
Notifications
You must be signed in to change notification settings - Fork 324
Closed
Description
Version: 0.7.0-p8
I'm trying to create an unpacker from a socket's input stream. It currently throws a NullPointerException
MessagePack msgPack = new MessagePack();
Socket socket = new Socket("127.0.0.1", 6666);
msgPack.newUnpacker(socket.getInputStream());
Stack Trace
Exception in thread "main" java.lang.NullPointerException: input channel is null
at org.msgpack.core.Preconditions.checkNotNull(Preconditions.java:203)
at org.msgpack.core.buffer.ChannelBufferInput.<init>(ChannelBufferInput.java:23)
at org.msgpack.core.buffer.ChannelBufferInput.<init>(ChannelBufferInput.java:19)
at org.msgpack.core.buffer.InputStreamBufferInput.newBufferInput(InputStreamBufferInput.java:21)
at org.msgpack.core.MessagePack.newUnpacker(MessagePack.java:360)
This happens inside InputStreamBufferInput.newBufferInput
since the InputStream from the socket is a FileInputStream
however It doesn't have a channel
public static MessageBufferInput newBufferInput(InputStream in) {
checkNotNull(in, "InputStream is null");
if (in instanceof FileInputStream) {
return new ChannelBufferInput(((FileInputStream) in).getChannel());
}
return new InputStreamBufferInput(in);
}
How should I create an unpacker from a socket?
Metadata
Metadata
Assignees
Labels
No labels