title: Hazelcast creates spring beans without dependencies
body: <p>This happens inside an application that runs in a Kubernetes cluster, built using spring boot. The instances of the application form an embedded hazelcast cluster. There is no client of that cluster outside of the application.</p>
  <p>A class implementing <code>Runnable</code> that depends on some injected beans, is scheduled on a hazelcast executor. After its initial execution, a different instance than the original is used - and its dependencies are not filled in.</p>
  <p>The class:</p>
  <pre><code>@SpringAware
  @Component
  public class RunnableClass implements Runnable, Serializable {
          private OneSpringBean dependency1;
          private AnotherSpringBean dependency2;
          
      @Autowired
      public RunnableClass(OneSpringBean dependency1, AnotherSpringBean dependency2, IScheduledExecutorService scheduler) {
          this.dependency1 = dependency1;
          this.dependency2 = dependency2;
          
          LOGGER.debug(&quot;[CONSTRUCTOR] Runnable class itself: {}&quot;, this);
          LOGGER.debug(&quot;[CONSTRUCTOR] Runnable dependency1: {}&quot;, this.dependency1);
          LOGGER.debug(&quot;[CONSTRUCTOR] Runnable dependency2: {}&quot;, this.dependency2);
          
          scheduler.scheduleAtFixedRate(this, 0L, 60, TimeUnit.SECONDS);
      }
  
      @Override
      public void run() {
          LOGGER.debug(&quot;[RUN] Runnable class itself: {}&quot;, this);
          LOGGER.debug(&quot;[RUN] Runnable dependency1: {}&quot;, this.dependency1);
          LOGGER.debug(&quot;[RUN] Runnable dependency2: {}&quot;, this.dependency2);
      }
  }
  </code></pre>
  <p>The relevant part of the log:</p>
  <pre><code>18:35:08.008 main com.some.package.RunnableClass:  [CONSTRUCTOR] Runnable class itself: com.some.package.RunnableClass@4eaa375c
  18:35:08.008 main com.some.package.RunnableClass:  [CONSTRUCTOR] Runnable class dependency1: com.some.package.OneSpringBean@bc6288b
  18:35:08.008 main com.some.package.RunnableClass:  [CONSTRUCTOR] Runnable class dependency2: com.some.package.AnotherSpringBean@7235f92b
  18:35:08.008 hz.quizzical_hoover.cached.thread-2 com.some.package.RunnableClass:  [RUN] Runnable class itself: com.some.package.RunnableClass@4eaa375c
  18:35:08.008 hz.quizzical_hoover.cached.thread-2 com.some.package.RunnableClass:  [RUN] Runnable class dependency1: com.some.package.OneSpringBean@bc6288b
  18:35:08.008 hz.quizzical_hoover.cached.thread-2 com.some.package.RunnableClass:  [RUN] Runnable class dependency2: com.some.package.AnotherSpringBean@7235f92b
  18:36:24.024 hz.quizzical_hoover.cached.thread-5 com.some.package.RunnableClass:  [RUN] Runnable class itself: com.some.package.RunnableClass@199c4dee
  18:36:24.024 hz.quizzical_hoover.cached.thread-5 com.some.package.RunnableClass:  [RUN] Runnable class dependency1: null
  18:36:24.024 hz.quizzical_hoover.cached.thread-5 com.some.package.RunnableClass:  [RUN] Runnable class dependency2: null
  18:46:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class itself: com.some.package.RunnableClass@199c4dee
  18:46:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class dependency1: null
  18:46:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class dependency2: null
  18:56:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class itself: com.some.package.RunnableClass@199c4dee
  18:56:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class dependency1: null
  18:56:24.024 hz.quizzical_hoover.cached.thread-3 com.some.package.RunnableClass:  [RUN] Runnable class dependency2: null
  </code></pre>
  <p>As can be seen, after the construction of the bean and the initial execution of the scheduled task, a new bean is created, and all subsequent executions of the scheduled task use that new bean - i.e. a new bean is not created on each execution.</p>
  <p>Although several instances of the application run, and form the embedded hazelcast cluster, the phenomenon can be seen on a single node. (I.e. the log excerpt above was copied from a single node.)</p>
  <p>Why is this happening? How can it be fixed?</p>