You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by bz...@apache.org on 2015/04/28 22:42:47 UTC
oozie git commit: OOZIE-2012 coordinator with an invalid cron
frequency throws NPE after validation (bzhang)
Repository: oozie
Updated Branches:
refs/heads/master e86b96d45 -> b1f5cf027
OOZIE-2012 coordinator with an invalid cron frequency throws NPE after validation (bzhang)
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/b1f5cf02
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/b1f5cf02
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/b1f5cf02
Branch: refs/heads/master
Commit: b1f5cf02758a8ec634302025bcc93fbbe88b5fcb
Parents: e86b96d
Author: Bowen Zhang <bo...@yahoo.com>
Authored: Tue Apr 28 13:42:02 2015 -0700
Committer: Bowen Zhang <bo...@yahoo.com>
Committed: Tue Apr 28 13:42:02 2015 -0700
----------------------------------------------------------------------
.../command/coord/CoordSubmitXCommand.java | 3 ++
.../command/coord/TestCoordSubmitXCommand.java | 34 ++++++++++++++++----
release-log.txt | 1 +
3 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oozie/blob/b1f5cf02/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
index 8c3db6d..ffb65d7 100644
--- a/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
@@ -359,6 +359,9 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
start = cal.getTime();
Date nextTime = CoordCommandUtils.getNextValidActionTimeForCronFrequency(start, coordJob);
+ if (nextTime == null) {
+ throw new IllegalArgumentException("Invalid coordinator cron frequency: " + coordJob.getFrequency());
+ }
if (!nextTime.before(coordJob.getEndTime())) {
throw new IllegalArgumentException("Coordinator job with frequency '" +
coordJob.getFrequency() + "' materializes no actions between start and end time.");
http://git-wip-us.apache.org/repos/asf/oozie/blob/b1f5cf02/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
index 5f72e57..e17d1b5 100644
--- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
+++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
@@ -182,23 +182,45 @@ public class TestCoordSubmitXCommand extends XDataTestCase {
}
public void testBasicSubmitWithCronFrequency() throws Exception {
- Configuration conf = new XConfiguration();
- File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"0 10 * * *\" start=\"2009-02-01T01:00Z\" "
+ "end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
+ "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> "
+ "<execution>LIFO</execution> </controls> <action> "
+ "<workflow> <app-path>hdfs:///tmp/workflows/</app-path> "
+ "</workflow> </action> </coordinator-app>";
+ testBasicSubmitWithCronFrequency(appXml, true);
+ appXml = "<coordinator-app name=\"NAME\" frequency=\"* * 30 FEB *\" start=\"2009-02-01T01:00Z\" "
+ + "end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
+ + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> "
+ + "<execution>LIFO</execution> </controls> <action> "
+ + "<workflow> <app-path>hdfs:///tmp/workflows/</app-path> "
+ + "</workflow> </action> </coordinator-app>";
+ testBasicSubmitWithCronFrequency(appXml, false);
+ }
+
+ private void testBasicSubmitWithCronFrequency(String appXml, Boolean isValidFrequency) throws Exception {
+ Configuration conf = new XConfiguration();
+ File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
- String jobId = sc.call();
- assertEquals(jobId.substring(jobId.length() - 2), "-C");
- CoordinatorJobBean job = (CoordinatorJobBean) sc.getJob();
- assertEquals(job.getTimeUnitStr(), "CRON");
+ if (isValidFrequency) {
+ String jobId = sc.call();
+ assertEquals(jobId.substring(jobId.length() - 2), "-C");
+ CoordinatorJobBean job = (CoordinatorJobBean) sc.getJob();
+ assertEquals(job.getTimeUnitStr(), "CRON");
+ }
+ else {
+ try {
+ String jobId = sc.call();
+ }
+ catch (Exception ex) {
+ assertTrue(ex.getMessage().contains("Invalid coordinator cron frequency"));
+ }
+ }
+
}
public void testBasicSubmitWithIdenticalStartAndEndTime() throws Exception {
http://git-wip-us.apache.org/repos/asf/oozie/blob/b1f5cf02/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index a0c4557..3745283 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 4.2.0 release (trunk - unreleased)
+OOZIE-2012 coordinator with an invalid cron frequency throws NPE after validation (bzhang)
OOZIE-2129 Duplicate child jobs per instance (jaydeepvishwakarma via shwethags)
OOZIE-2214 fix test case TestCoordRerunXCommand.testCoordRerunDateNeg (ryota)
OOZIE-2213 oozie-setup.ps1 should use "start-process" rather than "cmd /c" to invoke OozieSharelibCLI or OozieDBCLI commands (bzhang)