title: Why object is null though i have called the setter from my test code
body: <p>I have below code in my test method</p>
  
  <pre><code>VirtualServer virtualServer = new VirtualServer();
  virtualServer.initializeServlet();
  virtualServer.setServeletObserver(new ANFlipNotAllowedFlagObserver());
  .....
  .....
  </code></pre>
  
  <p>above 2 lines indicated as .... triggers dev code so that it hits my virtual server.</p>
  
  <p>Virtual server class has below code :-</p>
  
  <pre><code> public class VirtualServer extends HttpServlet
   {
      private volatile Observer observer;
  
      public synchronized Observer getServeletObserver ()
      {
         return observer;
      }
  
      public synchronized void setServeletObserver (Observer observer)
      {
          this.observer = observer;
      }
  
      protected void doPost (HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException
      {
          this.getServeletObserver().subject.setRequestResponse(request, response);
      }
  </code></pre>
  
  <p>When i put a breakpoint just after calling setServeletObserver and inspect the value of virtualserver.getServeletObserver i see the value i have set using my setting. If i set a breakpoint in my virtualServer class in dopost method (after calling the setting from testcode) i see the value of observer object as null. I am not sure why its null. My testclass already called  the setter method on this class. So it shouldnt be null. Can you please help me to findout whats wrong. I used volatile keyword for Observer object. But it didnt help.</p>