Created
November 6, 2012 07:30
-
-
Save jharjono/4023254 to your computer and use it in GitHub Desktop.
Snippet from Thrift's TSerializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Serialize the Thrift object into a byte array. The process is simple, | |
* just clear the byte array output, write the object into it, and grab the | |
* raw bytes. | |
* | |
* @param base The object to serialize | |
* @return Serialized object in byte[] format | |
*/ | |
public byte[] serialize(TBase base) throws TException { | |
baos_.reset(); | |
base.write(protocol_); | |
return baos_.toByteArray(); // what happens if another thread calls serialize() right before this line is executed? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment