title: FindBugs - "may fail to close stream" when using ObjectOutputStream
body: <p>I have this piece of code, which is to write an Ojbect to a byte array stream:</p>
  
  <pre><code>     static byte[] toBytes(MyTokens tokens) throws IOException {
          ByteArrayOutputStream out = null;
          ObjectOutput s = null;
          try {
              out = new ByteArrayOutputStream();
              try {
                  s = new ObjectOutputStream(out);
                  s.writeObject(tokens);
              } finally {
                  try {
                      s.close();
                  } catch (Exception e) {
                      throw new CSBRuntimeException(e);
                  }             
              }
          } catch (Exception e) {
              throw new CSBRuntimeException(e);
          } finally {
              IOUtils.closeQuietly(out);
          }
          return out.toByteArray();
      }
  </code></pre>
  
  <p>However, FindBugs keeps complaining about line: </p>
  
  <pre><code>s = new ObjectOutputStream(out);
  </code></pre>
  
  <p>that "may fail to close stream" - BAD_PRACTICE - OS_OPEN_STREAM. Can somebody help?</p>