title: Try-with-resources and return statements in java
body: <p>I'm wondering if putting a <em>return</em> statement inside a <em>try-with-resources</em> block prevents the resource to be automatically closed.</p>
  
  <pre><code>try(Connection conn = ...) {
      return conn.createStatement().execute("...");
  }
  </code></pre>
  
  <p>If I write something like this will the <em>Connection</em> be closed? In the Oracle documentation it is stated that:</p>
  
  <blockquote>
    <p>The try-with-resources statement ensures that each resource is closed at the end of the statement.</p>
  </blockquote>
  
  <p>What happens if the end of the statement is never reached because of a return statement?</p>