Skip to content

Commit a20e216

Browse files
committed
Changed: Remove the use of a static RequestOptions.empty which was error-prone with a mutable instance
1 parent acbcf89 commit a20e216

28 files changed

+175
-176
lines changed

algoliasearch-common/src/main/java/com/algolia/search/APIClient.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void close() throws AlgoliaException {
5353
* @return A List of the indices and their metadata
5454
*/
5555
public List<Index.Attributes> listIndexes() throws AlgoliaException {
56-
return listIndexes(RequestOptions.empty);
56+
return listIndexes(new RequestOptions());
5757
}
5858

5959
/**
@@ -79,7 +79,7 @@ public List<Index.Attributes> listIndexes(@Nonnull RequestOptions requestOptions
7979
/** Deprecated: use {@link #listIndexes()} */
8080
@Deprecated
8181
public List<Index.Attributes> listIndices() throws AlgoliaException {
82-
return listIndexes(RequestOptions.empty);
82+
return listIndexes(new RequestOptions());
8383
}
8484

8585
/** Deprecated: use {@link #listIndexes(RequestOptions)} */
@@ -125,7 +125,7 @@ public Analytics initAnalytics() {
125125
*/
126126
public Task moveIndex(@Nonnull String srcIndexName, @Nonnull String dstIndexName)
127127
throws AlgoliaException {
128-
return moveIndex(srcIndexName, dstIndexName, RequestOptions.empty);
128+
return moveIndex(srcIndexName, dstIndexName, new RequestOptions());
129129
}
130130

131131
/**
@@ -165,7 +165,7 @@ public Task moveIndex(
165165
*/
166166
public Task copyIndex(@Nonnull String srcIndexName, @Nonnull String dstIndexName)
167167
throws AlgoliaException {
168-
return copyIndex(srcIndexName, dstIndexName, RequestOptions.empty);
168+
return copyIndex(srcIndexName, dstIndexName, new RequestOptions());
169169
}
170170

171171
/**
@@ -226,7 +226,7 @@ public Task copyIndex(
226226
public Task copyIndex(
227227
@Nonnull String srcIndexName, @Nonnull String dstIndexName, @Nonnull List<String> scope)
228228
throws AlgoliaException {
229-
return copyIndex(srcIndexName, dstIndexName, scope, RequestOptions.empty);
229+
return copyIndex(srcIndexName, dstIndexName, scope, new RequestOptions());
230230
}
231231

232232
/**
@@ -236,7 +236,7 @@ public Task copyIndex(
236236
* @return The associated task
237237
*/
238238
public Task deleteIndex(@Nonnull String indexName) throws AlgoliaException {
239-
return deleteIndex(indexName, RequestOptions.empty);
239+
return deleteIndex(indexName, new RequestOptions());
240240
}
241241

242242
/**
@@ -266,7 +266,7 @@ public Task deleteIndex(@Nonnull String indexName, @Nonnull RequestOptions reque
266266
* @return A List<Log>
267267
*/
268268
public List<Log> getLogs() throws AlgoliaException {
269-
return getLogs(RequestOptions.empty);
269+
return getLogs(new RequestOptions());
270270
}
271271

272272
/**
@@ -300,7 +300,7 @@ public List<Log> getLogs(@Nonnull RequestOptions requestOptions) throws AlgoliaE
300300
public List<Log> getLogs(
301301
@Nonnull Integer offset, @Nonnull Integer length, @Nonnull LogType logType)
302302
throws AlgoliaException {
303-
return this.getLogs(offset, length, logType, RequestOptions.empty);
303+
return this.getLogs(offset, length, logType, new RequestOptions());
304304
}
305305

306306
/**
@@ -351,7 +351,7 @@ public List<ApiKey> listKeys() throws AlgoliaException {
351351
* @return A List of Keys
352352
*/
353353
public List<ApiKey> listApiKeys() throws AlgoliaException {
354-
return this.listApiKeys(RequestOptions.empty);
354+
return this.listApiKeys(new RequestOptions());
355355
}
356356

357357
/**
@@ -386,7 +386,7 @@ public Optional<ApiKey> getKey(@Nonnull String key) throws AlgoliaException {
386386
* @return the key
387387
*/
388388
public Optional<ApiKey> getApiKey(@Nonnull String key) throws AlgoliaException {
389-
return this.getApiKey(key, RequestOptions.empty);
389+
return this.getApiKey(key, new RequestOptions());
390390
}
391391

392392
/**
@@ -420,7 +420,7 @@ public DeleteKey deleteKey(@Nonnull String key) throws AlgoliaException {
420420
* @param key name of the key
421421
*/
422422
public DeleteKey deleteApiKey(@Nonnull String key) throws AlgoliaException {
423-
return deleteApiKey(key, RequestOptions.empty);
423+
return deleteApiKey(key, new RequestOptions());
424424
}
425425

426426
/**
@@ -453,7 +453,7 @@ public CreateUpdateKey addKey(@Nonnull ApiKey key) throws AlgoliaException {
453453
* @return the metadata of the key (such as it's name)
454454
*/
455455
public CreateUpdateKey addApiKey(@Nonnull ApiKey key) throws AlgoliaException {
456-
return addApiKey(key, RequestOptions.empty);
456+
return addApiKey(key, new RequestOptions());
457457
}
458458

459459
/**
@@ -491,7 +491,7 @@ public CreateUpdateKey updateKey(@Nonnull String keyName, @Nonnull ApiKey key)
491491
*/
492492
public CreateUpdateKey updateApiKey(@Nonnull String keyName, @Nonnull ApiKey key)
493493
throws AlgoliaException {
494-
return updateApiKey(keyName, key, RequestOptions.empty);
494+
return updateApiKey(keyName, key, new RequestOptions());
495495
}
496496

497497
/**
@@ -549,7 +549,7 @@ public String generateSecuredApiKey(
549549
* @param task the task to wait
550550
*/
551551
public <T> void waitTask(@Nonnull GenericTask<T> task) throws AlgoliaException {
552-
waitTask(task, 100L, RequestOptions.empty);
552+
waitTask(task, 100L, new RequestOptions());
553553
}
554554

555555
/**
@@ -559,7 +559,7 @@ public <T> void waitTask(@Nonnull GenericTask<T> task) throws AlgoliaException {
559559
* @param timeToWait the time to wait in milliseconds
560560
*/
561561
public <T> void waitTask(@Nonnull GenericTask<T> task, long timeToWait) throws AlgoliaException {
562-
waitTask(task, timeToWait, RequestOptions.empty);
562+
waitTask(task, timeToWait, new RequestOptions());
563563
}
564564

565565
/**
@@ -613,7 +613,7 @@ public <T> void waitTask(
613613
*/
614614
public TasksMultipleIndex batch(@Nonnull List<BatchOperation> operations)
615615
throws AlgoliaException {
616-
return batch(operations, RequestOptions.empty);
616+
return batch(operations, new RequestOptions());
617617
}
618618

619619
/**
@@ -658,7 +658,7 @@ public TasksMultipleIndex batch(
658658
*/
659659
public MultiQueriesResult multipleQueries(@Nonnull List<IndexQuery> queries)
660660
throws AlgoliaException {
661-
return multipleQueries(queries, RequestOptions.empty);
661+
return multipleQueries(queries, new RequestOptions());
662662
}
663663

664664
/**
@@ -685,7 +685,7 @@ public MultiQueriesResult multipleQueries(
685685
public MultiQueriesResult multipleQueries(
686686
@Nonnull List<IndexQuery> queries, @Nonnull MultiQueriesStrategy strategy)
687687
throws AlgoliaException {
688-
return multipleQueries(queries, strategy, RequestOptions.empty);
688+
return multipleQueries(queries, strategy, new RequestOptions());
689689
}
690690

691691
/**
@@ -1389,7 +1389,7 @@ public TaskABTest addABTest(ABTest abtest) throws AlgoliaException {
13891389
HttpMethod.POST,
13901390
AlgoliaRequestKind.ANALYTICS_API,
13911391
Arrays.asList("2", "abtests"),
1392-
RequestOptions.empty,
1392+
new RequestOptions(),
13931393
TaskABTest.class)
13941394
.setData(abtest));
13951395
}
@@ -1400,7 +1400,7 @@ public TaskABTest stopABTest(long id) throws AlgoliaException {
14001400
HttpMethod.POST,
14011401
AlgoliaRequestKind.ANALYTICS_API,
14021402
Arrays.asList("2", "abtests", Long.toString(id), "stop"),
1403-
RequestOptions.empty,
1403+
new RequestOptions(),
14041404
TaskABTest.class));
14051405
}
14061406

@@ -1410,7 +1410,7 @@ public TaskABTest deleteABTest(long id) throws AlgoliaException {
14101410
HttpMethod.DELETE,
14111411
AlgoliaRequestKind.ANALYTICS_API,
14121412
Arrays.asList("2", "abtests", Long.toString(id)),
1413-
RequestOptions.empty,
1413+
new RequestOptions(),
14141414
TaskABTest.class));
14151415
}
14161416

@@ -1420,7 +1420,7 @@ public ABTest getABTest(long id) throws AlgoliaException {
14201420
HttpMethod.GET,
14211421
AlgoliaRequestKind.ANALYTICS_API,
14221422
Arrays.asList("2", "abtests", Long.toString(id)),
1423-
RequestOptions.empty,
1423+
new RequestOptions(),
14241424
ABTest.class));
14251425
}
14261426

@@ -1430,7 +1430,7 @@ public ABTests getABTests(int offset, int limit) throws AlgoliaException {
14301430
HttpMethod.GET,
14311431
AlgoliaRequestKind.ANALYTICS_API,
14321432
Arrays.asList("2", "abtests"),
1433-
RequestOptions.empty,
1433+
new RequestOptions(),
14341434
ABTests.class)
14351435
.setParameters(
14361436
ImmutableMap.of(
@@ -1439,7 +1439,7 @@ public ABTests getABTests(int offset, int limit) throws AlgoliaException {
14391439
}
14401440

14411441
public List<Cluster> listClusters() throws AlgoliaException {
1442-
return this.listClusters(RequestOptions.empty);
1442+
return this.listClusters(new RequestOptions());
14431443
}
14441444

14451445
public List<Cluster> listClusters(@Nonnull RequestOptions requestOptions)
@@ -1461,7 +1461,7 @@ public UserIDs listUserIDs() throws AlgoliaException {
14611461
}
14621462

14631463
public UserIDs listUserIDs(Integer page, Integer hitsPerPage) throws AlgoliaException {
1464-
return this.listUserIDs(page, hitsPerPage, RequestOptions.empty);
1464+
return this.listUserIDs(page, hitsPerPage, new RequestOptions());
14651465
}
14661466

14671467
public UserIDs listUserIDs(
@@ -1479,7 +1479,7 @@ public UserIDs listUserIDs(
14791479
}
14801480

14811481
public Map<String, List<UserID>> getTopUserID() throws AlgoliaException {
1482-
return this.getTopUserID(RequestOptions.empty);
1482+
return this.getTopUserID(new RequestOptions());
14831483
}
14841484

14851485
public Map<String, List<UserID>> getTopUserID(RequestOptions requestOptions)
@@ -1498,7 +1498,7 @@ public Map<String, List<UserID>> getTopUserID(RequestOptions requestOptions)
14981498

14991499
public AssignUserID assignUserID(@Nonnull String userID, @Nonnull String clusterName)
15001500
throws AlgoliaException {
1501-
return this.assignUserID(userID, clusterName, RequestOptions.empty);
1501+
return this.assignUserID(userID, clusterName, new RequestOptions());
15021502
}
15031503

15041504
public AssignUserID assignUserID(
@@ -1517,7 +1517,7 @@ public AssignUserID assignUserID(
15171517
}
15181518

15191519
public UserID getUserID(@Nonnull String userID) throws AlgoliaException {
1520-
return this.getUserID(userID, RequestOptions.empty);
1520+
return this.getUserID(userID, new RequestOptions());
15211521
}
15221522

15231523
public UserID getUserID(@Nonnull String userID, RequestOptions requestOptions)
@@ -1540,7 +1540,7 @@ public UserID getUserID(@Nonnull String userID, RequestOptions requestOptions)
15401540
}
15411541

15421542
public DeleteUserID removeUserID(@Nonnull String userID) throws AlgoliaException {
1543-
return this.removeUserID(userID, RequestOptions.empty);
1543+
return this.removeUserID(userID, new RequestOptions());
15441544
}
15451545

15461546
public DeleteUserID removeUserID(@Nonnull String userID, RequestOptions requestOptions)

0 commit comments

Comments
 (0)