You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Cheolsoo Park (JIRA)" <ji...@apache.org> on 2014/02/18 15:08:23 UTC

[jira] [Updated] (PIG-3746) NPE is thrown if Pig fails before PigStats is intialized

     [ https://issues.apache.org/jira/browse/PIG-3746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Cheolsoo Park updated PIG-3746:
-------------------------------

    Attachment: PIG-3746-1.patch

PigStats is not initialized means PigServer hasn't started yet. So setError\[Messages|Code|Throwable\]() can simply exit in that case.

Attached is a patch that adds null checks to setError\[Messages|Code|Throwable\]().

> NPE is thrown if Pig fails before PigStats is intialized
> --------------------------------------------------------
>
>                 Key: PIG-3746
>                 URL: https://issues.apache.org/jira/browse/PIG-3746
>             Project: Pig
>          Issue Type: Bug
>            Reporter: Cheolsoo Park
>            Assignee: Cheolsoo Park
>             Fix For: 0.13.0
>
>         Attachments: PIG-3746-1.patch
>
>
> This is a regression of PIG-3525 where I moved the initialization of PigStats into the PigServer constructor. The problem is that if Pig fails even before PigServer is created, PigStats remains null resulting in NPE in PigStatsUtil.
> {code:title=PigStatsUtil}
>     public static void setErrorMessage(String msg) {
>         PigStats.get().setErrorMessage(msg); //---> PigStats.get() returns null
>     }
>     public static void setErrorCode(int code) {
>         PigStats.get().setErrorCode(code); //---> PigStats.get() returns null
>     }
> {code}
> To reproduce the issue, run the following command-
> {code}
> pig -x -f script.pig  #---> Note -x is missing the argument
> {code}
> The stack trace looks like this-
> {code}
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.pig.tools.pigstats.PigStatsUtil.setErrorMessage(PigStatsUtil.java:145)
> 	at org.apache.pig.Main.run(Main.java:618)
> 	at org.apache.pig.Main.main(Main.java:156)
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)