title: Observable.notifyObservers NullPointerException
body: <p>I try to implement the Observer pattern in one of my activities and face the following exception when calling <code>notifyObservers</code>:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke interface method
    'int java.util.List.size()' on a null object reference</p>
    
    <p>at java.util.Observable.notifyObservers(Observable.java:131)</p>
    
    <p>at models.database.User.setPending(User.java:137)</p>
  </blockquote>
  
  <p>My implementation is pretty straightforward: the model <code>User</code> is the observable and the activity is the observer (which shouldn't matter because the activity code is never reached). My goal is to be notified about every change in the field's properties.</p>
  
  <p>This is the relevant part in <code>User</code> class:</p>
  
  <pre><code>public class User extends Observable implements Parcelable {
  
      private boolean pending;
  
      public void setPending(boolean pending) {
          synchronized (this) {
              this.pending = pending;
          }
          setChanged();
          notifyObservers(this);
      }
  }
  </code></pre>
  
  <p>Is there any flaw in my implementation or in my understanding here? I have no idea what's wrong and I prefer to solve it rather than move to the RX implementation.</p>
  
  <p><strong>EDIT:</strong> This is the <code>MainActivity</code> code, which is never reached:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      //Get session variables from previous activity (LoginActivity/SplashActivity)
      user = getIntent().getExtras().getParcelable(getString(R.string.e_user)); //Receiving user from previous activity, assured to be non-null
  
      //Add observer on user, so we'll be able to update drawer in case of modification
      user.addObserver(this);
  }
  
  @Override
  public void update(Observable observable, Object o) {
      drawerBuilder.setUser(user);
  }
  </code></pre>