static public Buffer toUnframedBuffer(MessageBuffer message) { try { int size = message.serializedSizeUnframed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeUnframed(output); Buffer rc = baos.toBuffer(); assert rc.length == size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
static public Buffer toUnframedBuffer(MessageBuffer message) { try { int size = message.serializedSizeUnframed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeUnframed(output); Buffer rc = baos.toBuffer(); assert rc.length == size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
static public Buffer toUnframedBuffer(MessageBuffer message) { try { int size = message.serializedSizeUnframed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeUnframed(output); Buffer rc = baos.toBuffer(); assert rc.length == size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }