Throw an WatcherSettingsException when parsing an invalid hourly schedule.
``` "schedule" : { "hourly" : [0] } ``` Was throwing an NPE now it gives a WatcherSettingsException. Fixes: elastic/elasticsearch#419 Original commit: elastic/x-pack-elasticsearch@f334712f96
This commit is contained in:
parent
f5c50c44de
commit
2e787fff2b
|
@ -10,11 +10,12 @@ package org.elasticsearch.watcher;
|
|||
*/
|
||||
public class WatcherSettingsException extends WatcherException {
|
||||
|
||||
public WatcherSettingsException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
public WatcherSettingsException(String msg, Object... args) {
|
||||
super(msg, args);
|
||||
}
|
||||
|
||||
public WatcherSettingsException(String msg) {
|
||||
super(msg);
|
||||
public WatcherSettingsException(String msg, Throwable cause, Object... args) {
|
||||
super(msg, cause, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class CronSchedule extends CronnableSchedule {
|
|||
private String expression;
|
||||
|
||||
public ValidationException(String expression, Cron.ParseException cause) {
|
||||
super("invalid cron expression [" + expression + "]. " + cause.getMessage());
|
||||
super("invalid cron expression [{}]", cause, expression);
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ public class HourlySchedule extends CronnableSchedule {
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (currentFieldName == null) {
|
||||
throw new WatcherSettingsException("could not parse [{}] schedule. unexpected token [{}]", TYPE, token);
|
||||
} else if (MINUTE_FIELD.match(currentFieldName)) {
|
||||
if (token.isValue()) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue