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

NullPointerException when ZMQ_TCP_ACCEPT_FILTER is used #412

Closed
tjamesturner opened this issue Mar 30, 2017 · 1 comment
Closed

NullPointerException when ZMQ_TCP_ACCEPT_FILTER is used #412

tjamesturner opened this issue Mar 30, 2017 · 1 comment

Comments

@tjamesturner
Copy link
Contributor

tjamesturner commented Mar 30, 2017

if you call Options::setSocketOpt with zmq.ZMQ.ZMQ_TCP_ACCEPT_FILTER, it either has no effect (e.g. because everything matches the filter) or it causes a NullPointerException inside TcpListener. this NullPointerException escapes the Poller::run loop which prevents any future connections (and causes other problems).

here is a short self contained complete example:

public void testAcceptFilter() throws Exception
{
	ZContext context = new ZContext();
	ZMQ.Socket socket = context.createSocket(ZMQ.SUB);
	socket.base().setSocketOpt(zmq.ZMQ.ZMQ_TCP_ACCEPT_FILTER, "8.8.8.8:8090");
	socket.bind("tcp://*:8090");
	ZMQ.Socket pubSocket = context.createSocket(ZMQ.PUB);
	pubSocket.connect("tcp://127.0.0.1:8090");
}

here is a sample stack trace produced by the above test:

Exception in thread "iothread-2" java.lang.NullPointerException
	at zmq.Utils.tuneTcpSocket(Utils.java:37)
	at zmq.TcpListener.acceptEvent(TcpListener.java:72)
	at zmq.IOObject.acceptEvent(IOObject.java:104)
	at zmq.Poller.run(Poller.java:231)
	at java.lang.Thread.run(Thread.java:745)

in order to fix the issue, we either need to add a null check to TcpListener::acceptEvent or throw an IOException from TcpListener::accept instead of returning null. i prefer the later solution and will submit a pull request shortly.

tjamesturner added a commit to tjamesturner/jeromq that referenced this issue Mar 30, 2017
c-rack added a commit that referenced this issue Mar 30, 2017
#412 tcp accept filter null pointer exception fix
@tjamesturner
Copy link
Contributor Author

pull request #413 has fixed this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant