[zeromq-dev] Java binding proposed changes

Martin Sustrik sustrik at 250bpm.com
Mon Apr 5 10:49:49 CEST 2010


>>> The rule of the thumb is: When the problem shouldn't happen - i.e.
>>> there's a bug in 0MQ of Java binding - assert. If the problem can be
>>> caused by the user raise an exception.
>> Ok, if that is the rule there are several assert() calls that will
> stay
>> the same; perhaps all of them. I will report back.
> Find attached a patch that does the following:
> * Move the raise_exception() function to a separate util.{hpp,cpp} file;
> it is used from Socket.cpp and Poller.cpp.
> * Use assert() only when signaling an error that the user cannot do
> anything about; in all other cases, raise an exception.
> * Check the error code returned by all calls to 0MQ functions (there
> were a few missing). When checking this, always do (rc != 0) instead of
> (rc == -1).
> * After a call to a 0MQ function, assign errno to err; this is to ensure
> errno is not overwritten after the 0MQ call but before raising an
> exception that reports that error.
> * Make sure multiple initialization / finalizations of Context and
> Socket have no effect, to allow explicit calls to term() / close().
> I know I have write access to the Java binding repo, but I prefer to
> show my changes before committing them. Any comments before I do?

All the proposed changes seem entirely reasonable. Specifically, the 
error handling is pretty creaky, impoving it is really valuable.


More information about the zeromq-dev mailing list