You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Alex Levenson (JIRA)" <ji...@apache.org> on 2012/12/03 23:04:00 UTC

[jira] [Commented] (PIG-2645) PigSplit does not handle the case where SerializationFactory returns null

    [ https://issues.apache.org/jira/browse/PIG-2645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13509101#comment-13509101 ] 

Alex Levenson commented on PIG-2645:
------------------------------------

Style nitpicks:
Don't use a javadoc, use a regular comment
Comment probably not even needed
No need for the else clause

How about:
{code}
if (s == null) {
  throw new IllegalArgumentException("Could not find serializer for class " 
            + wrappedSplits[0].getClass() 
            + ". InputSplits should implement Writable.");
}
s.open((OutputStream) os);
for (int i = 0; i < wrappedSplits.length; i++)
{code}
                
> PigSplit does not handle the case where SerializationFactory returns null
> -------------------------------------------------------------------------
>
>                 Key: PIG-2645
>                 URL: https://issues.apache.org/jira/browse/PIG-2645
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.10.0
>            Reporter: Alex Levenson
>              Labels: patch
>         Attachments: PIG-2645.patch
>
>
> In PigSplit.java, line 254:
> {code}
> SerializationFactory sf = new SerializationFactory(conf);
> Serializer s = sf.getSerializer(wrappedSplits[0].getClass());
> s.open((OutputStream) os);
> {code}
> sf.getSerializer returns null when it cannot find a serializer for a given object. Instead of handling this properly, a NPE is thrown when s.open() is called.
> This is easy to encounter when creating a custom InputSplit from the mapreduce package which is an abstract class that DOES NOT implement Writable.
> However it's easy to miss because InputSplit from the mapred package is an interface that extends Writable, and InputSplits often both extend and implement both the new and old InputSplit abstract class and interface (thereby becoming Writable).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira