FindBugs - "pode falhar ao fechar fluxo" ao usar ObjectOutputStream
Eu tenho este pedaço de código, que é escrever um Ojbect para um fluxo 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();
}
No entanto, FindBugs continua reclamando sobre a linha:
s = new ObjectOutputStream(out);
que "pode falhar ao fechar fluxo" - BAD_PRACTICE - OS_OPEN_STREAM. Alguém pode ajudar?