GeezerVison is showing github.com — InputStream from Socket throws NullPointerException for Unpacker · Issue #217 · msgpack/msgpack-java
InputStream from Socket throws NullPointerException for Unpacker #217
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?
Activity
xerial commented on Apr 27, 2015
Thanks for the report. I'll add a fix when getChannel() is null.
added a commit that references this issue
on Apr 27, 2015This issue will close once commit 3dbe178 is merged into the 'v07-develop' branch.3dbe178 added a commit that references this issue
on Apr 27, 2015This issue will close once commit 28e5e7f is merged into the 'main' branch.28e5e7f xerial commented on Apr 27, 2015
Try 0.7.0-p9, which will be available in a few hours.
Metadata
Metadata
Development
No branches or pull requestsIssue actions