Program: 103158
Project: 103158
Buggy source:
/** 
 * Updates account information when a protocol provider is registered.
 * @param evt the <tt>RegistrationStateChangeEvent</tt> that notified usof the change
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  ProtocolProviderService protocolProvider=evt.getProvider();
  this.updateStatus(protocolProvider);
  if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    OperationSetServerStoredAccountInfo accountInfoOpSet=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (accountInfoOpSet != null) {
      new UpdateAccountInfo(protocolProvider,accountInfoOpSet).start();
    }
    OperationSetAvatar avatarOpSet=protocolProvider.getOperationSet(OperationSetAvatar.class);
    if (avatarOpSet != null)     avatarOpSet.addAvatarListener(this);
    OperationSetServerStoredAccountInfo serverStoredAccountInfo=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (serverStoredAccountInfo != null)     serverStoredAccountInfo.addServerStoredDetailsChangeListener(this);
  }
 else   if (evt.getNewState().equals(RegistrationState.UNREGISTERING) || evt.getNewState().equals(RegistrationState.CONNECTION_FAILED)) {
    OperationSetAvatar avatarOpSet=protocolProvider.getOperationSet(OperationSetAvatar.class);
    if (avatarOpSet != null)     avatarOpSet.removeAvatarListener(this);
    OperationSetServerStoredAccountInfo serverStoredAccountInfo=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (serverStoredAccountInfo != null)     serverStoredAccountInfo.removeServerStoredDetailsChangeListener(this);
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERING)) {
    startConnecting(protocolProvider);
  }
}

Fixed version (ground truth):
/** 
 * Updates account information when a protocol provider is registered.
 * @param evt the <tt>RegistrationStateChangeEvent</tt> that notified usof the change
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  ProtocolProviderService protocolProvider=evt.getProvider();
  if (!evt.getNewState().equals(RegistrationState.REGISTERING))   this.updateStatus(protocolProvider);
  if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    OperationSetServerStoredAccountInfo accountInfoOpSet=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (accountInfoOpSet != null) {
      new UpdateAccountInfo(protocolProvider,accountInfoOpSet).start();
    }
    OperationSetAvatar avatarOpSet=protocolProvider.getOperationSet(OperationSetAvatar.class);
    if (avatarOpSet != null)     avatarOpSet.addAvatarListener(this);
    OperationSetServerStoredAccountInfo serverStoredAccountInfo=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (serverStoredAccountInfo != null)     serverStoredAccountInfo.addServerStoredDetailsChangeListener(this);
  }
 else   if (evt.getNewState().equals(RegistrationState.UNREGISTERING) || evt.getNewState().equals(RegistrationState.CONNECTION_FAILED)) {
    OperationSetAvatar avatarOpSet=protocolProvider.getOperationSet(OperationSetAvatar.class);
    if (avatarOpSet != null)     avatarOpSet.removeAvatarListener(this);
    OperationSetServerStoredAccountInfo serverStoredAccountInfo=protocolProvider.getOperationSet(OperationSetServerStoredAccountInfo.class);
    if (serverStoredAccountInfo != null)     serverStoredAccountInfo.removeServerStoredDetailsChangeListener(this);
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERING)) {
    startConnecting(protocolProvider);
  }
}