title: Does Spring make sure Closeable beans are closed in the correct order?
body: <p>Let's pretend that we have two <code>Closeable</code> beans:</p>
  
  <pre><code>@Component
  public class CloseableBean1 implements Closeable {
  
      private BufferedOutputStream outputStream;
  
      @Override
      public void close() throws IOException {
          try {
              outputStream.close();
          } catch (Exception e) {
              // ignore e
          }
      }
  }
  
  
  @Component
  public class CloseableBean2 implements Closeable {    
  
      @Autowired
      private CloseableBean1 bean1;
  
  
      @Override
      public void close() throws IOException {
          try {
              bean1.close();
          } catch (Exception e) {
              // ignore e
          }
      }
  }
  </code></pre>
  
  <p>Does Spring make sure that <code>CloseableBean2</code> is closed first and then <code>CloseableBean1</code> is closed?</p>