/** * Closes the stream ignoring {@link IOException}. Must only be called in * cleaning up from exception handlers. * * @param stream * the Stream to close */ public static void closeStream(Closeable stream) { cleanup(null, stream); }
/** * Closes the stream ignoring {@link IOException}. Must only be called in * cleaning up from exception handlers. * * @param stream * the Stream to close */ public static void closeStream(Closeable stream) { cleanup(null, stream); }
public static byte[] serializeRequest(Request request) { if (request == null || request.getHdr() == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos); try { request.getHdr().serialize(boa, "hdr"); if (request.getTxn() != null) { request.getTxn().serialize(boa, "txn"); } } catch (IOException e) { LOG.error("This really should be impossible", e); } finally { IOUtils.cleanup(LOG, baos); } return baos.toByteArray(); } }