5
5
*/
6
6
package org .elasticsearch .xpack .watcher .execution ;
7
7
8
- import org .elasticsearch .common .CheckedSupplier ;
9
8
import org .elasticsearch .common .unit .TimeValue ;
10
9
import org .elasticsearch .xpack .core .watcher .actions .Action ;
11
10
import org .elasticsearch .xpack .core .watcher .actions .ActionWrapper ;
@@ -29,18 +28,19 @@ public class ManualExecutionContext extends WatchExecutionContext {
29
28
private final Map <String , ActionExecutionMode > actionModes ;
30
29
private final boolean recordExecution ;
31
30
private final boolean knownWatch ;
32
- private final Watch watch ;
33
31
34
32
ManualExecutionContext (Watch watch , boolean knownWatch , DateTime executionTime , ManualTriggerEvent triggerEvent ,
35
33
TimeValue defaultThrottlePeriod , Input .Result inputResult , Condition .Result conditionResult ,
36
- Map <String , ActionExecutionMode > actionModes , boolean recordExecution ) {
34
+ Map <String , ActionExecutionMode > actionModes , boolean recordExecution ) throws Exception {
37
35
38
36
super (watch .id (), executionTime , triggerEvent , defaultThrottlePeriod );
39
37
40
38
this .actionModes = actionModes ;
41
39
this .recordExecution = recordExecution ;
42
40
this .knownWatch = knownWatch ;
43
- this .watch = watch ;
41
+
42
+ // set the watch early to ensure calls to watch() below succeed.
43
+ super .ensureWatchExists (() -> watch );
44
44
45
45
if (inputResult != null ) {
46
46
onInputResult (inputResult );
@@ -66,12 +66,6 @@ public class ManualExecutionContext extends WatchExecutionContext {
66
66
}
67
67
}
68
68
69
- // a noop operation, as the watch is already loaded via ctor
70
- @ Override
71
- public void ensureWatchExists (CheckedSupplier <Watch , Exception > supplier ) throws Exception {
72
- super .ensureWatchExists (() -> watch );
73
- }
74
-
75
69
@ Override
76
70
public boolean knownWatch () {
77
71
return knownWatch ;
@@ -107,11 +101,6 @@ public final boolean recordExecution() {
107
101
return recordExecution ;
108
102
}
109
103
110
- @ Override
111
- public Watch watch () {
112
- return watch ;
113
- }
114
-
115
104
public static Builder builder (Watch watch , boolean knownWatch , ManualTriggerEvent event , TimeValue defaultThrottlePeriod ) {
116
105
return new Builder (watch , knownWatch , event , defaultThrottlePeriod );
117
106
}
@@ -173,7 +162,7 @@ public Builder withCondition(Condition.Result conditionResult) {
173
162
return this ;
174
163
}
175
164
176
- public ManualExecutionContext build () {
165
+ public ManualExecutionContext build () throws Exception {
177
166
if (executionTime == null ) {
178
167
executionTime = DateTime .now (DateTimeZone .UTC );
179
168
}
0 commit comments