GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

New issue
Copy link
New issue
Copy link
Closed
Closed
InputStream from Socket throws NullPointerException for Unpacker#217
Copy link

Description

@fdinoff
fdinoff
opened on Apr 27, 2015
Issue body actions

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

  1. xerial commented on Apr 27, 2015

    @xerial
    xerial
    on Apr 27, 2015
    Member
    More actions

    Thanks for the report. I'll add a fix when getChannel() is null.

  2. xerial
    added a commit that references this issue on Apr 27, 2015

    Fixes msgpack#217: Handle when FileInputStream.getChannel() returns null

    This issue will close once commit 3dbe178 is merged into the 'v07-develop' branch.
    3dbe178
  3. xerial
    closed this as completedin 3dbe178on Apr 27, 2015
  4. komamitsu
    added a commit that references this issue on Apr 27, 2015

    Merge pull request #218 from xerial/fix-input-stream

    This issue will close once commit 28e5e7f is merged into the 'main' branch.
    28e5e7f
  5. xerial commented on Apr 27, 2015

    @xerial
    xerial
    on Apr 27, 2015
    Member
    More actions

    Try 0.7.0-p9, which will be available in a few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.