diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 926161a9b2..e1c1771509 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -375,6 +375,9 @@ Release 0.23.1 - Unreleased MAPREDUCE-3604. Fixed streaming to use new mapreduce.framework.name to check for local mode. (acmurthy) + MAPREDUCE-3521. Fixed streaming to ensure it doesn't silently ignore + unknown arguments. (Robert Evans via acmurthy) + Release 0.23.0 - 2011-11-01 INCOMPATIBLE CHANGES diff --git a/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamJob.java b/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamJob.java index 3a0689d870..39ba36d179 100644 --- a/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamJob.java +++ b/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamJob.java @@ -255,6 +255,13 @@ void parseArgv() { } if (cmdLine != null) { + @SuppressWarnings("unchecked") + List args = cmdLine.getArgList(); + if(args != null && args.size() > 0) { + fail("Found " + args.size() + " unexpected arguments on the " + + "command line " + args); + } + detailedUsage_ = cmdLine.hasOption("info"); if (cmdLine.hasOption("help") || detailedUsage_) { printUsage = true; diff --git a/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/TestStreamJob.java b/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/TestStreamJob.java index 3ba37a845d..3e9036fca9 100644 --- a/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/TestStreamJob.java +++ b/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/TestStreamJob.java @@ -32,7 +32,18 @@ * This class tests hadoop Streaming's StreamJob class. */ public class TestStreamJob { - + + @Test(expected = IllegalArgumentException.class) + public void testCreateJobWithExtraArgs() throws IOException { + ArrayList dummyArgs = new ArrayList(); + dummyArgs.add("-input"); dummyArgs.add("dummy"); + dummyArgs.add("-output"); dummyArgs.add("dummy"); + dummyArgs.add("-mapper"); dummyArgs.add("dummy"); + dummyArgs.add("dummy"); + dummyArgs.add("-reducer"); dummyArgs.add("dummy"); + StreamJob.createJob(dummyArgs.toArray(new String[] {})); + } + @Test public void testCreateJob() throws IOException { JobConf job;