Cheolsoo Park created PIG-3746:
----------------------------------
Summary: 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
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)