[rabbitmq-discuss] Java RabbitMQ API bug in response.getHeaders()?

Michael Bridgen mikeb at rabbitmq.com
Thu Oct 27 21:35:31 BST 2011


Mario,

> If you really think that checking the headers before accessing them is
> an essential part of the AMQP specification (which I don't),  then an
> alternative way could be to explicitly enforce this as:
>
> Map getSentHeaders() throws HeadersNotSentException{...}
>
> Which will throw a HeadersNotSentException  when the headers are not
> present. This will still force me to add more code, but at least there
> won't be an overloading of null, which is really unconfortable, and the
> correct error message will be raised instead of the cryptic
> NullPointerException later on the code when I actually use the header
> reference.

I happen to agree the null isn't very convenient in the API. However I 
am curious to know what you mean by null being "overloaded": what are 
the two (or more?) meanings you think are being ascribed it?

Throwing an exception is an awful solution. Much better I think to have 
a known, immutable, empty value that can be used in an equality test.

-Michael


More information about the rabbitmq-discuss mailing list