title: Resource leak: 'in' is never closed, though it IS closed
body: <p>I know that there are a couple of similarly entitled questions out there, but most of them have simply forgotten to put a <code>close()</code> directive on their stream. This here is different.</p>
  
  <p>Lets say I have the following minimal example:</p>
  
  <pre><code>public void test() throws IOException
  {
      InputStream in;
      if( file.exists() )
      {
          in = new FileInputStream( file );
      }
      else
      {
          in = new URL( "some url" ).openStream();
      }
      in.close();
  }
  </code></pre>
  
  <p>This give me a <code>Resource leak: 'in' is never closed</code> warning in Eclipse (Juno SR1).
  But when I move the <code>in.close()</code> into the conditional block, the warnings vanishes:</p>
  
  <pre><code>public void test() throws IOException
  {
      InputStream in;
      if( file.exists() )
      {
          in = new GZIPInputStream( new FileInputStream( file ) );
          in.close();
      }
      else
      {
          in = new URL( "some URL" ).openStream();
      }
  }
  </code></pre>
  
  <p>What is going on here?</p>