FindBugs: "puede fallar al cerrar la secuencia" cuando se usa ObjectOutputStream
Tengo este fragmento de código, que es escribir un objeto en un flujo de matriz de bytes:
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();
}
Sin embargo, FindBugs sigue quejándose de la línea:
s = new ObjectOutputStream(out);
que "puede fallar al cerrar la secuencia" - BAD_PRACTICE - OS_OPEN_STREAM. ¿Alguien puede ayudar?