From 8fcc25c96e13a1c5bfd5f6e795e5ee6f84e20c4a Mon Sep 17 00:00:00 2001 From: Bharathwaj G Date: Tue, 19 Jul 2022 15:31:26 +0530 Subject: [PATCH] Addressing review comments Signed-off-by: Bharathwaj G --- .../java/org/opensearch/search/DefaultSearchContext.java | 3 ++- .../org/opensearch/search/DefaultSearchContextTests.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/DefaultSearchContext.java b/server/src/main/java/org/opensearch/search/DefaultSearchContext.java index 4d1d774ceb817..4bc40610facf2 100644 --- a/server/src/main/java/org/opensearch/search/DefaultSearchContext.java +++ b/server/src/main/java/org/opensearch/search/DefaultSearchContext.java @@ -49,6 +49,7 @@ import org.opensearch.common.lucene.search.Queries; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.BigArrays; +import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; import org.opensearch.index.cache.bitset.BitsetFilterCache; @@ -309,7 +310,7 @@ public void preProcess(boolean rewrite) { int sliceLimit = indexService.getIndexSettings().getMaxSlicesPerPit(); int numSlices = sliceBuilder.getMax(); if (numSlices > sliceLimit) { - throw new IllegalArgumentException( + throw new OpenSearchRejectedExecutionException( "The number of slices [" + numSlices + "] is too large. It must " diff --git a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java index 367257aaad5c6..98a5d34364632 100644 --- a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java +++ b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java @@ -52,6 +52,7 @@ import org.opensearch.common.util.BigArrays; import org.opensearch.common.util.MockBigArrays; import org.opensearch.common.util.MockPageCacheRecycler; +import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; import org.opensearch.index.cache.IndexCache; @@ -434,9 +435,9 @@ protected Engine.Searcher acquireSearcherInternal(String source) { when(sliceBuilder.getMax()).thenReturn(numSlicesForPit); context5.sliceBuilder(sliceBuilder); - exception = expectThrows(IllegalArgumentException.class, () -> context5.preProcess(false)); + OpenSearchRejectedExecutionException exception1 = expectThrows(OpenSearchRejectedExecutionException.class, () -> context5.preProcess(false)); assertThat( - exception.getMessage(), + exception1.getMessage(), equalTo( "The number of slices [" + numSlicesForPit