Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit e4c06c2

Browse files
author
Clément Le Provost
committed
Add assertion for mirrored state in mixed online/offline request
Such a request should never occur when the index is not mirrored.
1 parent 5cceac3 commit e4c06c2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

algoliasearch/src/offline/java/com/algolia/search/saas/MirroredIndex.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ private abstract class OnlineOfflineRequest implements Request {
647647
* Construct a new mixed online/offline request.
648648
*/
649649
public OnlineOfflineRequest(@NonNull CompletionHandler completionHandler) {
650+
if (!mirrored) {
651+
throw new IllegalStateException("This index is not mirrored");
652+
}
650653
this.completionHandler = completionHandler;
651654
}
652655

@@ -678,7 +681,7 @@ public OnlineOfflineRequest start() {
678681
// Since most methods use the main thread for callbacks, we have to use it as well.
679682

680683
// If the strategy is "offline only", well, go offline straight away.
681-
if (requestStrategy == Strategy.OFFLINE_ONLY && mirrored) {
684+
if (requestStrategy == Strategy.OFFLINE_ONLY) {
682685
startOffline();
683686
}
684687
// Otherwise, always launch an online request.

0 commit comments

Comments
 (0)