emopers created PIG-4795:
----------------------------
Summary: Flushing ObjectOutputStream before calling toByteArray on
the underlying ByteArrayOutputStream
Key: PIG-4795
URL: https://issues.apache.org/jira/browse/PIG-4795
Project: Pig
Issue Type: Bug
Reporter: emopers
In PigSplit.java
{code}
private void writeObject(Serializable obj, DataOutput os)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
byte[] bytes = baos.toByteArray();
os.writeInt(bytes.length);
os.write(bytes);
}
{code}
When an ObjectOutputStream instance wraps an underlying ByteArrayOutputStream
instance,
it is recommended to flush or close the ObjectOutputStream before invoking the
underlying instances's toByteArray(). Also, it is a good practice to call
flush/close explicitly as mentioned for example at
http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java.
The patch adds a flush method before calling toByteArray().
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)