[
https://issues.apache.org/jira/browse/PIG-4795?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Dai updated PIG-4795:
----------------------------
Resolution: Fixed
Assignee: emopers
Hadoop Flags: Reviewed
Fix Version/s: 0.16.0
Status: Resolved (was: Patch Available)
I don't see any downside.
Patch committed to trunk. Thanks [~emopers]
> 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
> Assignee: emopers
> Priority: Minor
> Labels: easyfix, patch
> Fix For: 0.16.0
>
> Attachments: PIG-4795-0.patch
>
>
> 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)