title: Android - Uncaught exception thrown by finalizer
body: <p>I have this piece of code that takes the server response and writes it into a file. </p>
  
  <p>The file contains json data. I write response into file in order to scan json sequentially and to avoid to load big json data in a List!</p>
  
  <p>I Think exception is thrown in this method but I'm not sure!</p>
  
  <pre><code>public File getData(final String url) throws URISyntaxException, AuthenticationException, IOException, ClientProtocolException, HttpResponseException {
      final HttpGet getRequest = new HttpGet(new URI(url));
  
      final UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
      getRequest.addHeader(new BasicScheme().authenticate(creds, getRequest));
      getRequest.setHeader("Content-Type", "application/json");
      final ResponseHandler&lt;byte[]&gt; responseHandler = new ByteArrayResponseHandler();
      final byte[] responseBody = mClient.execute(getRequest, responseHandler);
  
      final File output = new File(FileConfig.TEMP_PATH + System.currentTimeMillis()+".json");
      final FileOutputStream fos = new FileOutputStream(output.getPath()); 
  
      fos.write(responseBody);
      fos.close();
      return output;
  }
  </code></pre>
  
  <p>But I've noticed that recently (I don't know why) I get this exception:</p>
  
  <pre><code>01-22 07:45:51.809: E/System(9055): Uncaught exception thrown by finalizer
  01-22 07:45:51.833: E/System(9055): java.io.IOException: close failed: EIO (I/O error)
  01-22 07:45:51.833: E/System(9055):     at libcore.io.IoUtils.close(IoUtils.java:41)
  01-22 07:45:51.833: E/System(9055):     at java.io.FileInputStream.close(FileInputStream.java:121)
  01-22 07:45:51.833: E/System(9055):     at java.io.FileInputStream.finalize(FileInputStream.java:142)
  01-22 07:45:51.833: E/System(9055):     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:185)
  01-22 07:45:51.833: E/System(9055):     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
  01-22 07:45:51.833: E/System(9055):     at java.lang.Thread.run(Thread.java:856)
  01-22 07:45:51.833: E/System(9055): Caused by: libcore.io.ErrnoException: close failed: EIO (I/O error)
  01-22 07:45:51.833: E/System(9055):     at libcore.io.Posix.close(Native Method)
  01-22 07:45:51.833: E/System(9055):     at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
  01-22 07:45:51.833: E/System(9055):     at libcore.io.IoUtils.close(IoUtils.java:38)
  01-22 07:45:51.833: E/System(9055):     ... 5 more
  01-22 07:45:51.833: E/System(9055): Uncaught exception thrown by finalizer
  01-22 07:45:51.841: E/System(9055): java.io.IOException: close failed: EIO (I/O error)
  01-22 07:45:51.841: E/System(9055):     at libcore.io.IoUtils.close(IoUtils.java:41)
  01-22 07:45:51.841: E/System(9055):     at java.io.FileInputStream.close(FileInputStream.java:121)
  01-22 07:45:51.841: E/System(9055):     at java.io.FileInputStream.finalize(FileInputStream.java:142)
  01-22 07:45:51.841: E/System(9055):     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:185)
  01-22 07:45:51.841: E/System(9055):     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
  01-22 07:45:51.841: E/System(9055):     at java.lang.Thread.run(Thread.java:856)
  01-22 07:45:51.841: E/System(9055): Caused by: libcore.io.ErrnoException: close failed: EIO (I/O error)
  01-22 07:45:51.841: E/System(9055):     at libcore.io.Posix.close(Native Method)
  01-22 07:45:51.841: E/System(9055):     at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
  01-22 07:45:51.841: E/System(9055):     at libcore.io.IoUtils.close(IoUtils.java:38)
  01-22 07:45:51.841: E/System(9055):     ... 5 more
  </code></pre>
  
  <p>Everything seems to work, but I'm perplexed about this exception. </p>
  
  <p>The targetSdk ok my app is 13.</p>
  
  <p>Thanks for any comment / response!</p>