Program: 117503
Project: 117503
Buggy source:
static int run(String args[],PigProgressNotificationListener listener){
  int rc=1;
  boolean verbose=false;
  boolean gruntCalled=false;
  String logFileName=null;
  try {
    Configuration conf=new Configuration(false);
    GenericOptionsParser parser=new GenericOptionsParser(conf,args);
    conf=parser.getConfiguration();
    Properties properties=new Properties();
    PropertiesUtil.loadDefaultProperties(properties);
    properties.putAll(ConfigurationUtil.toProperties(conf));
    if (listener == null) {
      listener=makeListener(properties);
    }
    String[] pigArgs=parser.getRemainingArgs();
    boolean userSpecifiedLog=false;
    boolean checkScriptOnly=false;
    BufferedReader pin=null;
    boolean debug=false;
    boolean dryrun=false;
    boolean embedded=false;
    List<String> params=new ArrayList<String>();
    List<String> paramFiles=new ArrayList<String>();
    HashSet<String> disabledOptimizerRules=new HashSet<String>();
    CmdLineParser opts=new CmdLineParser(pigArgs);
    opts.registerOpt('4',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('b',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('c',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('d',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('e',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('f',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('g',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('h',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('i',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('l',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('m',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('p',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('r',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('t',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('v',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('w',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('x',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('F',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('M',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('P',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    ExecMode mode=ExecMode.UNKNOWN;
    String file=null;
    String engine=null;
    ExecType execType=ExecType.MAPREDUCE;
    String execTypeString=properties.getProperty("String_Node_Str");
    if (execTypeString != null && execTypeString.length() > 0) {
      execType=ExecType.fromString(execTypeString);
    }
    UDFContext.getUDFContext().setClientSystemProps(properties);
    char opt;
    while ((opt=opts.getNextOpt()) != CmdLineParser.EndOfOpts) {
switch (opt) {
case '4':
        String log4jconf=opts.getValStr();
      if (log4jconf != null) {
        properties.setProperty(LOG4J_CONF,log4jconf);
      }
    break;
case 'b':
  properties.setProperty(BRIEF,"String_Node_Str");
break;
case 'c':
checkScriptOnly=true;
break;
case 'd':
String logLevel=opts.getValStr();
if (logLevel != null) {
properties.setProperty(DEBUG,logLevel);
}
debug=true;
break;
case 'e':
mode=ExecMode.STRING;
break;
case 'f':
mode=ExecMode.FILE;
file=opts.getValStr();
break;
case 'g':
embedded=true;
engine=opts.getValStr();
break;
case 'F':
properties.setProperty("String_Node_Str","String_Node_Str" + true);
break;
case 'h':
String topic=opts.getValStr();
if (topic != null) if (topic.equalsIgnoreCase("String_Node_Str")) printProperties();
 else {
System.out.println("String_Node_Str" + topic);
usage();
}
 else usage();
return ReturnCode.SUCCESS;
case 'i':
System.out.println(getVersionString());
return ReturnCode.SUCCESS;
case 'l':
String logFileParameter=opts.getValStr();
if (logFileParameter != null && logFileParameter.length() > 0) {
logFileName=validateLogFile(logFileParameter,null);
}
 else {
logFileName=validateLogFile(logFileName,null);
}
userSpecifiedLog=true;
properties.setProperty("String_Node_Str",(logFileName == null ? "String_Node_Str" : logFileName));
break;
case 'm':
paramFiles.add(opts.getValStr());
break;
case 'M':
properties.setProperty("String_Node_Str","String_Node_Str" + false);
break;
case 'p':
params.add(opts.getValStr());
break;
case 'r':
dryrun=true;
break;
case 't':
disabledOptimizerRules.add(opts.getValStr());
break;
case 'v':
properties.setProperty(VERBOSE,"String_Node_Str" + true);
verbose=true;
break;
case 'w':
properties.setProperty("String_Node_Str","String_Node_Str" + false);
break;
case 'x':
try {
execType=ExecType.fromString(opts.getValStr());
}
 catch (IOException e) {
throw new RuntimeException("String_Node_Str",e);
}
break;
case 'P':
{
InputStream inputStream=null;
try {
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,opts.getValStr());
inputStream=new BufferedInputStream(new FileInputStream(localFileRet.file));
properties.load(inputStream);
}
 catch (IOException e) {
throw new RuntimeException("String_Node_Str" + opts.getValStr() + "String_Node_Str");
}
 finally {
if (inputStream != null) {
try {
inputStream.close();
}
 catch (IOException e) {
}
}
}
}
break;
default :
{
Character cc=Character.valueOf(opt);
throw new AssertionError("String_Node_Str" + cc.toString());
}
}
}
PigContext pigContext=new PigContext(execType,properties);
String commandLine=LoadFunc.join((AbstractList<String>)Arrays.asList(args),"String_Node_Str");
ScriptState scriptState=ScriptState.start(commandLine,pigContext);
if (listener != null) {
scriptState.registerListener(listener);
}
pigContext.getProperties().setProperty("String_Node_Str",commandLine);
if (logFileName == null && !userSpecifiedLog) {
logFileName=validateLogFile(properties.getProperty("String_Node_Str"),null);
}
pigContext.getProperties().setProperty("String_Node_Str",(logFileName == null ? "String_Node_Str" : logFileName));
configureLog4J(properties,pigContext);
log.info(getVersionString().replace("String_Node_Str","String_Node_Str"));
if (logFileName != null) {
System.out.println("String_Node_Str");
log.info("String_Node_Str" + logFileName);
}
if (!Boolean.valueOf(properties.getProperty(PROP_FILT_SIMPL_OPT,"String_Node_Str"))) {
disabledOptimizerRules.add("String_Node_Str");
}
pigContext.getProperties().setProperty(PigImplConstants.PIG_OPTIMIZER_RULES_KEY,ObjectSerializer.serialize(disabledOptimizerRules));
PigContext.setClassLoader(pigContext.createCl(null));
Grunt grunt=null;
BufferedReader in;
String substFile=null;
paramFiles=fetchRemoteParamFiles(paramFiles,properties);
pigContext.setParams(params);
pigContext.setParamFiles(paramFiles);
switch (mode) {
case FILE:
{
String remainders[]=opts.getRemainingArgs();
if (remainders != null) {
pigContext.getProperties().setProperty(PigContext.PIG_CMD_ARGS_REMAINDERS,ObjectSerializer.serialize(remainders));
}
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,file);
if (localFileRet.didFetch) {
properties.setProperty("String_Node_Str","String_Node_Str");
}
scriptState.setFileName(file);
if (embedded) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),engine);
}
 else {
SupportedScriptLang type=determineScriptType(localFileRet.file.getPath());
if (type != null) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),type.name().toLowerCase());
}
}
in=new BufferedReader(new InputStreamReader(Utils.getCompositeStream(new FileInputStream(localFileRet.file),properties)));
substFile=file + "String_Node_Str";
pin=runParamPreprocessor(pigContext,in,substFile,debug || dryrun || checkScriptOnly);
if (dryrun) {
if (dryrun(substFile,pigContext)) {
log.info("String_Node_Str" + substFile + "String_Node_Str"+ file+ "String_Node_Str");
}
 else {
log.info("String_Node_Str" + substFile);
}
return ReturnCode.SUCCESS;
}
logFileName=validateLogFile(logFileName,file);
pigContext.getProperties().setProperty("String_Node_Str",logFileName);
pigContext.getProperties().setProperty(PigContext.JOB_NAME,"String_Node_Str" + new File(file).getName());
if (!debug) {
new File(substFile).deleteOnExit();
}
scriptState.setScript(new File(file));
grunt=new Grunt(pin,pigContext);
gruntCalled=true;
if (checkScriptOnly) {
grunt.checkScript(substFile);
System.err.println(file + "String_Node_Str");
rc=ReturnCode.SUCCESS;
}
 else {
int results[]=grunt.exec();
rc=getReturnCodeForStats(results);
}
return rc;
}
case STRING:
{
if (checkScriptOnly) {
System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
return ReturnCode.ILLEGAL_ARGS;
}
StringBuffer sb=new StringBuffer();
String remainders[]=opts.getRemainingArgs();
for (int i=0; i < remainders.length; i++) {
if (i != 0) sb.append(' ');
sb.append(remainders[i]);
}
sb.append('\n');
scriptState.setScript(sb.toString());
in=new BufferedReader(new StringReader(sb.toString()));
grunt=new Grunt(in,pigContext);
gruntCalled=true;
int results[]=grunt.exec();
return getReturnCodeForStats(results);
}
default :
break;
}
String remainders[]=opts.getRemainingArgs();
if (remainders == null) {
if (checkScriptOnly) {
System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
return ReturnCode.ILLEGAL_ARGS;
}
mode=ExecMode.SHELL;
ConsoleReader reader=new ConsoleReader(Utils.getCompositeStream(System.in,properties),new OutputStreamWriter(System.out));
reader.setDefaultPrompt("String_Node_Str");
final String HISTORYFILE="String_Node_Str";
String historyFile=System.getProperty("String_Node_Str") + File.separator + HISTORYFILE;
reader.setHistory(new History(new File(historyFile)));
ConsoleReaderInputStream inputStream=new ConsoleReaderInputStream(reader);
grunt=new Grunt(new BufferedReader(new InputStreamReader(inputStream)),pigContext);
grunt.setConsoleReader(reader);
gruntCalled=true;
grunt.run();
return ReturnCode.SUCCESS;
}
 else {
pigContext.getProperties().setProperty(PigContext.PIG_CMD_ARGS_REMAINDERS,ObjectSerializer.serialize(remainders));
mode=ExecMode.FILE;
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,remainders[0]);
if (localFileRet.didFetch) {
properties.setProperty("String_Node_Str","String_Node_Str");
}
scriptState.setFileName(remainders[0]);
if (embedded) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),engine);
}
 else {
SupportedScriptLang type=determineScriptType(localFileRet.file.getPath());
if (type != null) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),type.name().toLowerCase());
}
}
InputStream seqInputStream=Utils.getCompositeStream(new FileInputStream(localFileRet.file),properties);
in=new BufferedReader(new InputStreamReader(seqInputStream));
substFile=remainders[0] + "String_Node_Str";
pin=runParamPreprocessor(pigContext,in,substFile,debug || dryrun || checkScriptOnly);
if (dryrun) {
if (dryrun(substFile,pigContext)) {
log.info("String_Node_Str" + substFile + "String_Node_Str"+ remainders[0]+ "String_Node_Str");
}
 else {
log.info("String_Node_Str" + substFile);
}
return ReturnCode.SUCCESS;
}
logFileName=validateLogFile(logFileName,remainders[0]);
pigContext.getProperties().setProperty("String_Node_Str",logFileName);
if (!debug) {
new File(substFile).deleteOnExit();
}
pigContext.getProperties().setProperty(PigContext.JOB_NAME,"String_Node_Str" + new File(remainders[0]).getName());
scriptState.setScript(localFileRet.file);
grunt=new Grunt(pin,pigContext);
gruntCalled=true;
if (checkScriptOnly) {
grunt.checkScript(substFile);
System.err.println(remainders[0] + "String_Node_Str");
rc=ReturnCode.SUCCESS;
}
 else {
int results[]=grunt.exec();
rc=getReturnCodeForStats(results);
}
return rc;
}
}
 catch (ParseException e) {
usage();
rc=ReturnCode.PARSE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
catch (org.apache.pig.tools.parameters.ParseException e) {
rc=ReturnCode.PARSE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
catch (IOException e) {
if (e instanceof PigException) {
PigException pe=(PigException)e;
rc=(pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION : ReturnCode.PIG_EXCEPTION;
PigStatsUtil.setErrorMessage(pe.getMessage());
PigStatsUtil.setErrorCode(pe.getErrorCode());
}
 else {
rc=ReturnCode.IO_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
if (!gruntCalled) {
LogUtils.writeLog(e,logFileName,log,verbose,"String_Node_Str");
}
}
catch (Throwable e) {
rc=ReturnCode.THROWABLE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
if (!gruntCalled) {
LogUtils.writeLog(e,logFileName,log,verbose,"String_Node_Str");
}
}
 finally {
FileLocalizer.deleteTempFiles();
PerformanceTimerFactory.getPerfTimerFactory().dumpTimers();
}
return rc;
}

Fixed version (ground truth):
static int run(String args[],PigProgressNotificationListener listener){
  int rc=1;
  boolean verbose=false;
  boolean gruntCalled=false;
  String logFileName=null;
  bcaster=new BroadCastServer();
  bcaster.startBroadcastServer(Integer.parseInt(System.getenv("String_Node_Str")));
  try {
    Configuration conf=new Configuration(false);
    GenericOptionsParser parser=new GenericOptionsParser(conf,args);
    conf=parser.getConfiguration();
    Properties properties=new Properties();
    PropertiesUtil.loadDefaultProperties(properties);
    properties.putAll(ConfigurationUtil.toProperties(conf));
    if (listener == null) {
      listener=makeListener(properties);
    }
    String[] pigArgs=parser.getRemainingArgs();
    boolean userSpecifiedLog=false;
    boolean checkScriptOnly=false;
    BufferedReader pin=null;
    boolean debug=false;
    boolean dryrun=false;
    boolean embedded=false;
    List<String> params=new ArrayList<String>();
    List<String> paramFiles=new ArrayList<String>();
    HashSet<String> disabledOptimizerRules=new HashSet<String>();
    CmdLineParser opts=new CmdLineParser(pigArgs);
    opts.registerOpt('4',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('b',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('c',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('d',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('e',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('f',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('g',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('h',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('i',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('l',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('m',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('p',"String_Node_Str",CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('r',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('t',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('v',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('w',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('x',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('F',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('M',"String_Node_Str",CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('P',"String_Node_Str",CmdLineParser.ValueExpected.REQUIRED);
    ExecMode mode=ExecMode.UNKNOWN;
    String file=null;
    String engine=null;
    ExecType execType=ExecType.MAPREDUCE;
    String execTypeString=properties.getProperty("String_Node_Str");
    if (execTypeString != null && execTypeString.length() > 0) {
      execType=ExecType.fromString(execTypeString);
    }
    UDFContext.getUDFContext().setClientSystemProps(properties);
    char opt;
    while ((opt=opts.getNextOpt()) != CmdLineParser.EndOfOpts) {
switch (opt) {
case '4':
        String log4jconf=opts.getValStr();
      if (log4jconf != null) {
        properties.setProperty(LOG4J_CONF,log4jconf);
      }
    break;
case 'b':
  properties.setProperty(BRIEF,"String_Node_Str");
break;
case 'c':
checkScriptOnly=true;
break;
case 'd':
String logLevel=opts.getValStr();
if (logLevel != null) {
properties.setProperty(DEBUG,logLevel);
}
debug=true;
break;
case 'e':
mode=ExecMode.STRING;
break;
case 'f':
mode=ExecMode.FILE;
file=opts.getValStr();
break;
case 'g':
embedded=true;
engine=opts.getValStr();
break;
case 'F':
properties.setProperty("String_Node_Str","String_Node_Str" + true);
break;
case 'h':
String topic=opts.getValStr();
if (topic != null) if (topic.equalsIgnoreCase("String_Node_Str")) printProperties();
 else {
System.out.println("String_Node_Str" + topic);
usage();
}
 else usage();
return ReturnCode.SUCCESS;
case 'i':
System.out.println(getVersionString());
return ReturnCode.SUCCESS;
case 'l':
String logFileParameter=opts.getValStr();
if (logFileParameter != null && logFileParameter.length() > 0) {
logFileName=validateLogFile(logFileParameter,null);
}
 else {
logFileName=validateLogFile(logFileName,null);
}
userSpecifiedLog=true;
properties.setProperty("String_Node_Str",(logFileName == null ? "String_Node_Str" : logFileName));
break;
case 'm':
paramFiles.add(opts.getValStr());
break;
case 'M':
properties.setProperty("String_Node_Str","String_Node_Str" + false);
break;
case 'p':
params.add(opts.getValStr());
break;
case 'r':
dryrun=true;
break;
case 't':
disabledOptimizerRules.add(opts.getValStr());
break;
case 'v':
properties.setProperty(VERBOSE,"String_Node_Str" + true);
verbose=true;
break;
case 'w':
properties.setProperty("String_Node_Str","String_Node_Str" + false);
break;
case 'x':
try {
execType=ExecType.fromString(opts.getValStr());
}
 catch (IOException e) {
throw new RuntimeException("String_Node_Str",e);
}
break;
case 'P':
{
InputStream inputStream=null;
try {
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,opts.getValStr());
inputStream=new BufferedInputStream(new FileInputStream(localFileRet.file));
properties.load(inputStream);
}
 catch (IOException e) {
throw new RuntimeException("String_Node_Str" + opts.getValStr() + "String_Node_Str");
}
 finally {
if (inputStream != null) {
try {
inputStream.close();
}
 catch (IOException e) {
}
}
}
}
break;
default :
{
Character cc=Character.valueOf(opt);
throw new AssertionError("String_Node_Str" + cc.toString());
}
}
}
PigContext pigContext=new PigContext(execType,properties);
String commandLine=LoadFunc.join((AbstractList<String>)Arrays.asList(args),"String_Node_Str");
ScriptState scriptState=ScriptState.start(commandLine,pigContext);
if (listener != null) {
scriptState.registerListener(listener);
}
pigContext.getProperties().setProperty("String_Node_Str",commandLine);
if (logFileName == null && !userSpecifiedLog) {
logFileName=validateLogFile(properties.getProperty("String_Node_Str"),null);
}
pigContext.getProperties().setProperty("String_Node_Str",(logFileName == null ? "String_Node_Str" : logFileName));
configureLog4J(properties,pigContext);
log.info(getVersionString().replace("String_Node_Str","String_Node_Str"));
if (logFileName != null) {
System.out.println("String_Node_Str");
log.info("String_Node_Str" + logFileName);
}
if (!Boolean.valueOf(properties.getProperty(PROP_FILT_SIMPL_OPT,"String_Node_Str"))) {
disabledOptimizerRules.add("String_Node_Str");
}
pigContext.getProperties().setProperty(PigImplConstants.PIG_OPTIMIZER_RULES_KEY,ObjectSerializer.serialize(disabledOptimizerRules));
PigContext.setClassLoader(pigContext.createCl(null));
Grunt grunt=null;
BufferedReader in;
String substFile=null;
paramFiles=fetchRemoteParamFiles(paramFiles,properties);
pigContext.setParams(params);
pigContext.setParamFiles(paramFiles);
switch (mode) {
case FILE:
{
String remainders[]=opts.getRemainingArgs();
if (remainders != null) {
pigContext.getProperties().setProperty(PigContext.PIG_CMD_ARGS_REMAINDERS,ObjectSerializer.serialize(remainders));
}
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,file);
if (localFileRet.didFetch) {
properties.setProperty("String_Node_Str","String_Node_Str");
}
scriptState.setFileName(file);
if (embedded) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),engine);
}
 else {
SupportedScriptLang type=determineScriptType(localFileRet.file.getPath());
if (type != null) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),type.name().toLowerCase());
}
}
in=new BufferedReader(new InputStreamReader(Utils.getCompositeStream(new FileInputStream(localFileRet.file),properties)));
substFile=file + "String_Node_Str";
pin=runParamPreprocessor(pigContext,in,substFile,debug || dryrun || checkScriptOnly);
if (dryrun) {
if (dryrun(substFile,pigContext)) {
log.info("String_Node_Str" + substFile + "String_Node_Str"+ file+ "String_Node_Str");
}
 else {
log.info("String_Node_Str" + substFile);
}
return ReturnCode.SUCCESS;
}
logFileName=validateLogFile(logFileName,file);
pigContext.getProperties().setProperty("String_Node_Str",logFileName);
pigContext.getProperties().setProperty(PigContext.JOB_NAME,"String_Node_Str" + new File(file).getName());
if (!debug) {
new File(substFile).deleteOnExit();
}
scriptState.setScript(new File(file));
grunt=new Grunt(pin,pigContext);
gruntCalled=true;
if (checkScriptOnly) {
grunt.checkScript(substFile);
System.err.println(file + "String_Node_Str");
rc=ReturnCode.SUCCESS;
}
 else {
int results[]=grunt.exec();
rc=getReturnCodeForStats(results);
}
return rc;
}
case STRING:
{
if (checkScriptOnly) {
System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
return ReturnCode.ILLEGAL_ARGS;
}
StringBuffer sb=new StringBuffer();
String remainders[]=opts.getRemainingArgs();
for (int i=0; i < remainders.length; i++) {
if (i != 0) sb.append(' ');
sb.append(remainders[i]);
}
sb.append('\n');
scriptState.setScript(sb.toString());
in=new BufferedReader(new StringReader(sb.toString()));
grunt=new Grunt(in,pigContext);
gruntCalled=true;
int results[]=grunt.exec();
return getReturnCodeForStats(results);
}
default :
break;
}
String remainders[]=opts.getRemainingArgs();
if (remainders == null) {
if (checkScriptOnly) {
System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
return ReturnCode.ILLEGAL_ARGS;
}
mode=ExecMode.SHELL;
ConsoleReader reader=new ConsoleReader(Utils.getCompositeStream(System.in,properties),new OutputStreamWriter(System.out));
reader.setDefaultPrompt("String_Node_Str");
final String HISTORYFILE="String_Node_Str";
String historyFile=System.getProperty("String_Node_Str") + File.separator + HISTORYFILE;
reader.setHistory(new History(new File(historyFile)));
ConsoleReaderInputStream inputStream=new ConsoleReaderInputStream(reader);
grunt=new Grunt(new BufferedReader(new InputStreamReader(inputStream)),pigContext);
grunt.setConsoleReader(reader);
gruntCalled=true;
grunt.run();
return ReturnCode.SUCCESS;
}
 else {
pigContext.getProperties().setProperty(PigContext.PIG_CMD_ARGS_REMAINDERS,ObjectSerializer.serialize(remainders));
mode=ExecMode.FILE;
FileLocalizer.FetchFileRet localFileRet=FileLocalizer.fetchFile(properties,remainders[0]);
if (localFileRet.didFetch) {
properties.setProperty("String_Node_Str","String_Node_Str");
}
scriptState.setFileName(remainders[0]);
if (embedded) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),engine);
}
 else {
SupportedScriptLang type=determineScriptType(localFileRet.file.getPath());
if (type != null) {
return runEmbeddedScript(pigContext,localFileRet.file.getPath(),type.name().toLowerCase());
}
}
InputStream seqInputStream=Utils.getCompositeStream(new FileInputStream(localFileRet.file),properties);
in=new BufferedReader(new InputStreamReader(seqInputStream));
substFile=remainders[0] + "String_Node_Str";
pin=runParamPreprocessor(pigContext,in,substFile,debug || dryrun || checkScriptOnly);
if (dryrun) {
if (dryrun(substFile,pigContext)) {
log.info("String_Node_Str" + substFile + "String_Node_Str"+ remainders[0]+ "String_Node_Str");
}
 else {
log.info("String_Node_Str" + substFile);
}
return ReturnCode.SUCCESS;
}
logFileName=validateLogFile(logFileName,remainders[0]);
pigContext.getProperties().setProperty("String_Node_Str",logFileName);
if (!debug) {
new File(substFile).deleteOnExit();
}
pigContext.getProperties().setProperty(PigContext.JOB_NAME,"String_Node_Str" + new File(remainders[0]).getName());
scriptState.setScript(localFileRet.file);
grunt=new Grunt(pin,pigContext);
gruntCalled=true;
if (checkScriptOnly) {
grunt.checkScript(substFile);
System.err.println(remainders[0] + "String_Node_Str");
rc=ReturnCode.SUCCESS;
}
 else {
int results[]=grunt.exec();
rc=getReturnCodeForStats(results);
}
return rc;
}
}
 catch (ParseException e) {
usage();
rc=ReturnCode.PARSE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
catch (org.apache.pig.tools.parameters.ParseException e) {
rc=ReturnCode.PARSE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
catch (IOException e) {
if (e instanceof PigException) {
PigException pe=(PigException)e;
rc=(pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION : ReturnCode.PIG_EXCEPTION;
PigStatsUtil.setErrorMessage(pe.getMessage());
PigStatsUtil.setErrorCode(pe.getErrorCode());
}
 else {
rc=ReturnCode.IO_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
}
if (!gruntCalled) {
LogUtils.writeLog(e,logFileName,log,verbose,"String_Node_Str");
}
}
catch (Throwable e) {
rc=ReturnCode.THROWABLE_EXCEPTION;
PigStatsUtil.setErrorMessage(e.getMessage());
if (!gruntCalled) {
LogUtils.writeLog(e,logFileName,log,verbose,"String_Node_Str");
}
}
 finally {
FileLocalizer.deleteTempFiles();
PerformanceTimerFactory.getPerfTimerFactory().dumpTimers();
}
return rc;
}