Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-validate after read
Browse files Browse the repository at this point in the history
davidkyle committed Oct 15, 2018
1 parent 5a5f111 commit 2db0fe4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.xpack.core.ml.action.util.QueryPage;
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig;
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedJobValidator;
import org.elasticsearch.xpack.core.ml.job.config.DataDescription;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
@@ -125,11 +126,14 @@ void build(String datafeedId, JobResultsProvider jobResultsProvider, JobConfigPr
});
};

// Get the job config
// Get the job config and re-validate
// Re-validation is required as the config has been re-read since
// the previous validation
ActionListener<Job.Builder> jobConfigListener = ActionListener.wrap(
jobBuilder -> {
try {
jobHolder.set(jobBuilder.build());
DatafeedJobValidator.validate(datafeedConfigHolder.get(), jobHolder.get());
jobIdConsumer.accept(jobHolder.get().getId());
} catch (Exception e) {
listener.onFailure(e);

0 comments on commit 2db0fe4

Please sign in to comment.