Skip to content

Commit c5a3c3d

Browse files
authored
Fix watcher check that determines when to serialize indices options. (#78070)
The check was an identity check between the default constant and the set indices options. This check is incorrect because in many cases when `IndicesOptions` is parsed or randomly generated in tests, then this check incorrectly returns false when in fact an `IndicesOptions` instance is equal to the default constant, but it is just a different instance/object. Closes #78035
1 parent 533e244 commit c5a3c3d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
140140
builder.rawField(BODY_FIELD.getPreferredName(), stream);
141141
}
142142
}
143-
if (indicesOptions != DEFAULT_INDICES_OPTIONS) {
143+
if (indicesOptions.equals(DEFAULT_INDICES_OPTIONS) == false) {
144144
builder.startObject(INDICES_OPTIONS_FIELD.getPreferredName());
145145
indicesOptions.toXContent(builder, params);
146146
builder.endObject();

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public void testResponseToData() throws Exception {
9494
assertThat(result, equalTo(expected));
9595
}
9696

97-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/78035")
9897
public void testSerializeSearchRequest() throws Exception {
9998
String[] expectedIndices = generateRandomStringArray(5, 5, true);
10099
IndicesOptions expectedIndicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(),
@@ -155,7 +154,6 @@ public void testSerializeSearchRequest() throws Exception {
155154
}
156155
}
157156

158-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/78035")
159157
public void testDeserializeSearchRequest() throws Exception {
160158

161159
XContentBuilder builder = jsonBuilder().startObject();
@@ -175,9 +173,11 @@ public void testDeserializeSearchRequest() throws Exception {
175173
indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(),
176174
randomBoolean(), randomBoolean(), indicesOptions.allowAliasesToMultipleIndices(),
177175
indicesOptions.forbidClosedIndices(), indicesOptions.ignoreAliases(), indicesOptions.ignoreThrottled());
178-
builder.startObject("indices_options");
179-
indicesOptions.toXContent(builder, ToXContent.EMPTY_PARAMS);
180-
builder.endObject();
176+
if (indicesOptions.equals(DEFAULT_INDICES_OPTIONS) == false) {
177+
builder.startObject("indices_options");
178+
indicesOptions.toXContent(builder, ToXContent.EMPTY_PARAMS);
179+
builder.endObject();
180+
}
181181
}
182182

183183
SearchType searchType = SearchType.DEFAULT;

0 commit comments

Comments
 (0)