{
ProducerInfo info = getProducerInfo();
if (isModified())
{
// save old info in case something goes wrong
RegistrationInfo oldReg = getProducerInfo().getRegistrationInfo();
// get updated registration info
RegistrationInfo newReg = getExpectedRegistrationInfo();
// make sure we save any modified registration properties
saveToRegistry(info);
// check that we have the proper state
if (newReg == null)
{
// if we want to change an existing registration property (for example, to upgrade service) then there are
// no expected information, we're just using the modified local version
newReg = new RegistrationInfo(oldReg);
if (!isRegistrationLocallyModified())
{
IllegalStateException e =
new IllegalStateException("Registration not locally modified: there should be expected registration from producer!");