Skip to content

Commit 4ab01af

Browse files
committed
Spotless
1 parent 8da7611 commit 4ab01af

File tree

4 files changed

+146
-118
lines changed

4 files changed

+146
-118
lines changed

server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java

Lines changed: 112 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@ public void testCreateManySynonyms() throws Exception {
6363
DEFAULT_TIMEOUT,
6464
new ActionListener<>() {
6565
@Override
66-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
67-
assertEquals(
68-
SynonymsManagementAPIService.UpdateSynonymsResultStatus.CREATED,
69-
synonymsReloadResult.synonymsOperationResult()
70-
);
71-
putLatch.countDown();
72-
}
66+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
67+
assertEquals(
68+
SynonymsManagementAPIService.UpdateSynonymsResultStatus.CREATED,
69+
synonymsReloadResult.synonymsOperationResult()
70+
);
71+
putLatch.countDown();
72+
}
7373

74-
@Override
75-
public void onFailure(Exception e) {
76-
fail(e);
74+
@Override
75+
public void onFailure(Exception e) {
76+
fail(e);
77+
}
7778
}
78-
});
79+
);
7980

8081
putLatch.await(5, TimeUnit.SECONDS);
8182

@@ -137,65 +138,67 @@ public void testCreateTooManySynonymsUsingRuleUpdates() throws InterruptedExcept
137138
DEFAULT_TIMEOUT,
138139
new ActionListener<>() {
139140
@Override
140-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
141-
// Create as many rules as should fail
142-
SynonymRule[] rules = randomSynonymsSet(atLeast(rulesToUpdate + 1));
143-
CountDownLatch updatedRulesLatch = new CountDownLatch(rulesToUpdate);
144-
for (int i = 0; i < rulesToUpdate; i++) {
145-
synonymsManagementAPIService.putSynonymRule(synonymSetId, rules[i], DEFAULT_TIMEOUT, new ActionListener<>() {
146-
@Override
147-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
148-
updatedRulesLatch.countDown();
149-
}
150-
151-
@Override
152-
public void onFailure(Exception e) {
153-
fail(e);
154-
}
155-
});
156-
}
157-
try {
158-
updatedRulesLatch.await(5, TimeUnit.SECONDS);
159-
} catch (InterruptedException e) {
160-
fail(e);
161-
}
162-
163-
// Updating more rules fails
164-
int rulesToInsert = rules.length - rulesToUpdate;
165-
CountDownLatch insertRulesLatch = new CountDownLatch(rulesToInsert);
166-
for (int i = rulesToUpdate; i < rulesToInsert; i++) {
167-
synonymsManagementAPIService.putSynonymRule(
168-
// Error here
169-
synonymSetId,
170-
rules[i],
171-
DEFAULT_TIMEOUT, new ActionListener<>() {
141+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
142+
// Create as many rules as should fail
143+
SynonymRule[] rules = randomSynonymsSet(atLeast(rulesToUpdate + 1));
144+
CountDownLatch updatedRulesLatch = new CountDownLatch(rulesToUpdate);
145+
for (int i = 0; i < rulesToUpdate; i++) {
146+
synonymsManagementAPIService.putSynonymRule(synonymSetId, rules[i], DEFAULT_TIMEOUT, new ActionListener<>() {
172147
@Override
173148
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
174-
fail("Shouldn't have been able to update a rule");
149+
updatedRulesLatch.countDown();
175150
}
176151

177152
@Override
178153
public void onFailure(Exception e) {
179-
if (e instanceof IllegalArgumentException == false) {
180-
fail(e);
154+
fail(e);
155+
}
156+
});
157+
}
158+
try {
159+
updatedRulesLatch.await(5, TimeUnit.SECONDS);
160+
} catch (InterruptedException e) {
161+
fail(e);
162+
}
163+
164+
// Updating more rules fails
165+
int rulesToInsert = rules.length - rulesToUpdate;
166+
CountDownLatch insertRulesLatch = new CountDownLatch(rulesToInsert);
167+
for (int i = rulesToUpdate; i < rulesToInsert; i++) {
168+
synonymsManagementAPIService.putSynonymRule(
169+
// Error here
170+
synonymSetId,
171+
rules[i],
172+
DEFAULT_TIMEOUT,
173+
new ActionListener<>() {
174+
@Override
175+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
176+
fail("Shouldn't have been able to update a rule");
177+
}
178+
179+
@Override
180+
public void onFailure(Exception e) {
181+
if (e instanceof IllegalArgumentException == false) {
182+
fail(e);
183+
}
184+
updatedRulesLatch.countDown();
181185
}
182-
updatedRulesLatch.countDown();
183186
}
184-
}
185-
);
187+
);
188+
}
189+
try {
190+
insertRulesLatch.await(5, TimeUnit.SECONDS);
191+
} catch (InterruptedException e) {
192+
fail(e);
193+
}
186194
}
187-
try {
188-
insertRulesLatch.await(5, TimeUnit.SECONDS);
189-
} catch (InterruptedException e) {
195+
196+
@Override
197+
public void onFailure(Exception e) {
190198
fail(e);
191199
}
192200
}
193-
194-
@Override
195-
public void onFailure(Exception e) {
196-
fail(e);
197-
}
198-
});
201+
);
199202

200203
latch.await(5, TimeUnit.SECONDS);
201204
}
@@ -211,7 +214,8 @@ public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonym
211214
synonymsManagementAPIService.putSynonymRule(
212215
synonymSetId,
213216
synonymsSet[randomIntBetween(0, maxSynonymSets - 1)],
214-
DEFAULT_TIMEOUT, new ActionListener<>() {
217+
DEFAULT_TIMEOUT,
218+
new ActionListener<>() {
215219
@Override
216220
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
217221
latch.countDown();
@@ -243,17 +247,22 @@ public void testCreateRuleWithMaxSynonyms() throws InterruptedException {
243247
@Override
244248
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
245249
// Updating a rule fails
246-
synonymsManagementAPIService.putSynonymRule(synonymSetId, randomSynonymRule(ruleId), DEFAULT_TIMEOUT, new ActionListener<>() {
247-
@Override
248-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
249-
fail("Should not create a new rule that does not exist when at max capacity");
250-
}
250+
synonymsManagementAPIService.putSynonymRule(
251+
synonymSetId,
252+
randomSynonymRule(ruleId),
253+
DEFAULT_TIMEOUT,
254+
new ActionListener<>() {
255+
@Override
256+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
257+
fail("Should not create a new rule that does not exist when at max capacity");
258+
}
251259

252-
@Override
253-
public void onFailure(Exception e) {
254-
latch.countDown();
260+
@Override
261+
public void onFailure(Exception e) {
262+
latch.countDown();
263+
}
255264
}
256-
});
265+
);
257266
}
258267

259268
@Override
@@ -312,9 +321,11 @@ public void testCreateSynonymsWithYellowSynonymsIndex() throws Exception {
312321
@Override
313322
void checkSynonymsIndexHealth(TimeValue timeout, ActionListener<ClusterHealthResponse> listener) {
314323
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).build();
315-
ClusterHealthResponse response = new ClusterHealthResponse(randomIdentifier(),
316-
new String[]{SynonymsManagementAPIService.SYNONYMS_INDEX_CONCRETE_NAME},
317-
clusterState);
324+
ClusterHealthResponse response = new ClusterHealthResponse(
325+
randomIdentifier(),
326+
new String[] { SynonymsManagementAPIService.SYNONYMS_INDEX_CONCRETE_NAME },
327+
clusterState
328+
);
318329
response.setTimedOut(true);
319330
listener.onResponse(response);
320331
}
@@ -323,24 +334,20 @@ void checkSynonymsIndexHealth(TimeValue timeout, ActionListener<ClusterHealthRes
323334
// Create a rule fails
324335
CountDownLatch putLatch = new CountDownLatch(1);
325336
String synonymSetId = randomIdentifier();
326-
synonymsManagementAPIService.putSynonymsSet(
327-
synonymSetId,
328-
randomSynonymsSet(1, 1),
329-
DEFAULT_TIMEOUT,
330-
new ActionListener<>() {
331-
@Override
332-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
333-
fail("Shouldn't have been able to create synonyms with a timeout in synonyms index health");
334-
}
337+
synonymsManagementAPIService.putSynonymsSet(synonymSetId, randomSynonymsSet(1, 1), DEFAULT_TIMEOUT, new ActionListener<>() {
338+
@Override
339+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
340+
fail("Shouldn't have been able to create synonyms with a timeout in synonyms index health");
341+
}
335342

336-
@Override
337-
public void onFailure(Exception e) {
338-
// Expected
339-
assertTrue(e instanceof IndexCreationException);
340-
assertTrue(e.getMessage().contains("synonyms index [.synonyms] is not searchable"));
341-
putLatch.countDown();
342-
}
343-
});
343+
@Override
344+
public void onFailure(Exception e) {
345+
// Expected
346+
assertTrue(e instanceof IndexCreationException);
347+
assertTrue(e.getMessage().contains("synonyms index [.synonyms] is not searchable"));
348+
putLatch.countDown();
349+
}
350+
});
344351

345352
putLatch.await(5, TimeUnit.SECONDS);
346353

@@ -349,7 +356,8 @@ public void onFailure(Exception e) {
349356
synonymsManagementAPIService.putSynonymRule(
350357
synonymSetId,
351358
randomSynonymRule(randomIdentifier()),
352-
DEFAULT_TIMEOUT, new ActionListener<>() {
359+
DEFAULT_TIMEOUT,
360+
new ActionListener<>() {
353361
@Override
354362
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
355363
fail("Shouldn't have been able to update synonyms with a timeout in synonyms index health");
@@ -362,28 +370,25 @@ public void onFailure(Exception e) {
362370
assertTrue(e.getMessage().contains("synonyms index [.synonyms] is not searchable"));
363371
updateLatch.countDown();
364372
}
365-
});
373+
}
374+
);
366375

367376
updateLatch.await(5, TimeUnit.SECONDS);
368377

369378
// But, we can still create a synonyms set with timeout -1
370379
CountDownLatch putWithoutTimeoutLatch = new CountDownLatch(1);
371-
synonymsManagementAPIService.putSynonymsSet(
372-
synonymSetId,
373-
randomSynonymsSet(1, 1),
374-
TimeValue.MINUS_ONE,
375-
new ActionListener<>() {
376-
@Override
377-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
378-
// Expected
379-
putLatch.countDown();
380-
}
380+
synonymsManagementAPIService.putSynonymsSet(synonymSetId, randomSynonymsSet(1, 1), TimeValue.MINUS_ONE, new ActionListener<>() {
381+
@Override
382+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
383+
// Expected
384+
putLatch.countDown();
385+
}
381386

382-
@Override
383-
public void onFailure(Exception e) {
384-
fail(e);
385-
}
386-
});
387+
@Override
388+
public void onFailure(Exception e) {
389+
fail(e);
390+
}
391+
});
387392

388393
putWithoutTimeoutLatch.await(5, TimeUnit.SECONDS);
389394

@@ -404,7 +409,8 @@ public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonym
404409
public void onFailure(Exception e) {
405410
fail(e);
406411
}
407-
});
412+
}
413+
);
408414

409415
putRuleWithoutTimeoutLatch.await(5, TimeUnit.SECONDS);
410416
}

server/src/main/java/org/elasticsearch/action/synonyms/TransportPutSynonymRuleAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ protected void doExecute(Task task, PutSynonymRuleAction.Request request, Action
4141
synonymsManagementAPIService.putSynonymRule(
4242
request.synonymsSetId(),
4343
request.synonymRule(),
44-
request.timeout(), listener.map(SynonymUpdateResponse::new)
44+
request.timeout(),
45+
listener.map(SynonymUpdateResponse::new)
4546
);
4647
}
4748
}

server/src/main/java/org/elasticsearch/rest/action/synonyms/RestPutSynonymsAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.util.List;
2424

25-
import static org.elasticsearch.action.synonyms.PutSynonymRuleAction.DEFAULT_TIMEOUT;
2625
import static org.elasticsearch.rest.RestRequest.Method.PUT;
2726

2827
@ServerlessScope(Scope.PUBLIC)

0 commit comments

Comments
 (0)