I think FindBugs does not undestand that IOUtils.closeQuietly(out) closes out.
Anyway it is enough to close ObjectOutputStream and it will close underlying ByteArrayOutputStream. This is ObjectOutputStream.close implementation
public void close() throws IOException {
flush();
clear();
bout.close();
}
so you can simplify your code
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream s = new ObjectOutputStream(out);
try {
s.writeObject(1);
} finally {
IOUtils.closeQuietly(s);
}
or if you are in Java 7
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ObjectOutputStream s = new ObjectOutputStream(out)) {
s.writeObject(1);
}