Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to invoke virtual method 'java.io.InputStream java.net.Socket.getInputStream()' on a null object reference #188

Open
sergeushenecz opened this issue Apr 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@sergeushenecz
Copy link

Hello everyone. I see in the sentry sometimes this errors. Maybe someone are faced also with this issues?

@sergeushenecz sergeushenecz added the bug Something isn't working label Apr 12, 2024
@marianolc
Copy link

This is a bug(i think) that i "fixed" in the version I forked... i just changed the write() method in TcpSocketClient:

public void write(final int msgId, final byte[] data) {
        writeExecutor.execute(new Runnable() {
            @Override
            public void run() {
               // THIS IS THE FIX VALIDATION ***********************
                if (socket == null) {
                    receiverListener.onError(getId(), new IOException("Attempted to write to closed socket"));
                    return;
                }
                try {
                    socket.getOutputStream().write(data);
                    receiverListener.onWritten(getId(), msgId, null);
                } catch (IOException e) {
                    receiverListener.onWritten(getId(), msgId, e);
                    receiverListener.onError(getId(), e);
                }
            }
        });
    }

@sergeushenecz
Copy link
Author

And this code will fix problem? Maybe need to add pull request for it?

@sergeushenecz
Copy link
Author

@marianolc I've checked in library and see the same code as you wrote me. I don't understand where need to add fix.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants