title: Spring session scope bean reset between requests when accessing through zuul
body: <p>The spring app has a session bean, which contains certain data. That data is loaded from DB at <code>init</code> request to the controller, which is always a first request client calls at start up. That data is used for other requests by same user. Now, everything works fine on its own. However after trying to integrate the app into the system using zuul (which as far as I understand in this context simply redirects request from one url into another), it broke. Whenever a method is called after the <code>init</code>, the session bean's data is <code>null</code>. </p>
  
  <p>Here is a snippet from service class:</p>
  
  <pre><code>    @Autowired
      TaskCache cache;
  
  
      @Override
      public void initUserSession() {
          List&lt;Task&gt; data = loadTasks();
          cache.setTasks(data);
          LinearFilterStack&lt;Task&gt; fs = createFilterStack(data);
          cache.setFilterStack(fs);
  
          System.out.println(cache.hashCode()); //hashcode stays same
          System.out.println(cache.getFilterStack() == null) //false
      }
  
  
      @Override
      public List&lt;Task&gt; getTasks(Sort sort) {
          System.out.println(cache.hashCode()); //hashcode stays same
          System.out.println(cache.getFilterStack() == null) //true
          LinearFilterStack&lt;Task&gt; fs = cache.getFilterStack();
          List&lt;Task&gt; tasks = fs.filter(cache.getTasks()); //Obviously NPE
          sortTasks(tasks, sort);
          return tasks;
      }
  </code></pre>
  
  <hr>
  
  <pre><code>@Component
  @Scope(value=WebApplicationContext.SCOPE_SESSION, proxyMode=ScopedProxyMode.TARGET_CLASS)
  public class TaskCache { ... }
  </code></pre>
  
  <hr>
  
  <p>And again, this only happens through zuul. I.e. if I use localhost:30022/rest/... it works, if I use localhost:8080/app/tasks/rest/... (which zuul redirects to localhost:30022/rest/...) I get NPE, because the cache bean loses its data after init request.</p>