Calling ServiceBusContract.deleteMessage() can throw NullPointerException
Dev estimate: 2 Test estimate: 1
Calling ServiceBusContract.deleteMessage() on a BrokeredMessage obtained with ReceiveMode.RECEIVE_AND_DELETE will cause a NPE to be thrown from java.net.URI while parsing. This is due to the fact that BrokeredMessage.getLockLocation() returns a null value for messages retrieved with ReceiveMode.RECEIVE_AND_DELETE. While it's obviously a bad idea to call deleteMessage() on messages retrieved in this fashion, an NPE is not an appropriate response. Instead, ServiceBusRestProxy.deleteMessage() should test BrokeredMessage.getLockLocation() for a valid value and throw a ServiceException if it is not valid.
All IMNSO, of course.
Happy to do the tests/implementation as soon as I can get the CLA through my company's legal.
Bill
the same apply to unlock message.
However, the proposed change is breaking change which we cannot take. For example, if customer already capture NPE, now they need to capture ServiceException. In addition, this is not a service exception, it doesn't make sense to throw a service exception for null pointer.
I think customer should just check whether the lock duration is null before calling unlock message/delete message. Additional checking at service layer of SDK is not in scope, close for now.