mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 22:02:31 +08:00
SQOOP-114. Fix for NPE.
This is a fix for a case of malformed command line arguments, where the tool name is correct, the option is also correct, but the value of the option is missing. From: Ahmed Radwan <ahmed@cloudera.com> git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1149990 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e3638e8ce0
commit
5dd36c62da
@ -1017,7 +1017,7 @@
|
||||
<mkdir dir="${findbugs.out.dir}"/>
|
||||
<findbugs home="${findbugs.home}" output="xml:withMessages"
|
||||
outputFile="${findbugs.output.xml.file}" effort="max"
|
||||
excludeFilter="${findbugs.excludes}">
|
||||
excludeFilter="${findbugs.excludes}" jvmargs="-Xms512m -Xmx512m">
|
||||
<auxClasspath>
|
||||
<path refid="test.classpath"/>
|
||||
</auxClasspath>
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
@ -28,7 +27,7 @@
|
||||
import org.apache.hadoop.util.Tool;
|
||||
import org.apache.hadoop.util.ToolRunner;
|
||||
|
||||
import com.cloudera.sqoop.tool.HelpTool;
|
||||
import com.cloudera.sqoop.cli.ToolOptions;
|
||||
import com.cloudera.sqoop.tool.SqoopTool;
|
||||
|
||||
/**
|
||||
@ -121,13 +120,16 @@ public int run(String [] args) {
|
||||
options = tool.parseArguments(args, null, options, false);
|
||||
tool.appendArgs(this.childPrgmArgs);
|
||||
tool.validateOptions(options);
|
||||
} catch (ParseException pe) {
|
||||
// Couldn't parse arguments. Just print a usage message and exit.
|
||||
new HelpTool().run(new SqoopOptions(getConf()));
|
||||
return 1;
|
||||
} catch (SqoopOptions.InvalidOptionsException e) {
|
||||
// Error validating arguments. Print an error message and exit.
|
||||
} catch (Exception e) {
|
||||
// Couldn't parse arguments.
|
||||
// Log the stack trace for this exception
|
||||
LOG.debug(e.getMessage(), e);
|
||||
// Print exception message.
|
||||
System.err.println(e.getMessage());
|
||||
// Print the tool usage message and exit.
|
||||
ToolOptions toolOpts = new ToolOptions();
|
||||
tool.configureOptions(toolOpts);
|
||||
tool.printHelp(toolOpts);
|
||||
return 1; // Exit on exception here.
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ private void printAvailableTools() {
|
||||
/** {@inheritDoc} */
|
||||
public int run(SqoopOptions options) {
|
||||
|
||||
if (this.extraArguments.length > 0) {
|
||||
if (this.extraArguments != null && this.extraArguments.length > 0) {
|
||||
if (hasUnrecognizedArgs(extraArguments, 1, extraArguments.length)) {
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user