Skip to content
Snippets Groups Projects
Commit f670d8be authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

Merge branch 'master' into auth-optimization

parents b7dbecc9 914d2e5e
Branches
Tags
2 merge requests!469optimize geo queries: remove redundant call and use filter,!463optimize data authorization query
Pipeline #173650 failed
......@@ -76,6 +76,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
......@@ -428,6 +429,11 @@ abstract class QueryBase {
}
} catch (AppException e) {
throw e;
} catch (SocketTimeoutException e) {
if (e.getMessage().startsWith("60,000 milliseconds timeout on connection")) {
throw new AppException(HttpServletResponse.SC_GATEWAY_TIMEOUT, "Search error", String.format("Request timed out after waiting for %sm", REQUEST_TIMEOUT.getMinutes()), e);
}
throw new AppException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Search error", "Error processing search request", e);
} catch (IOException e) {
if (e.getMessage().startsWith("listener timeout after waiting for")) {
throw new AppException(HttpServletResponse.SC_GATEWAY_TIMEOUT, "Search error", String.format("Request timed out after waiting for %sm", REQUEST_TIMEOUT.getMinutes()), e);
......
......@@ -81,6 +81,7 @@ import org.opengroup.osdu.search.util.QueryParserUtil;
import org.opengroup.osdu.search.util.SortParserUtil;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
......@@ -525,6 +526,27 @@ public class QueryServiceImplTest {
}
}
@Test(expected = AppException.class)
public void testQueryBase_SocketTimeoutException_ListenerTimeout_throwsException() throws IOException {
SocketTimeoutException exception = mock(SocketTimeoutException.class);
Set<String> indexedTypes = new HashSet<>();
String dummyTimeoutMessage = "60,000 milliseconds timeout on connection";
doThrow(exception).when(client).search(any(), any(RequestOptions.class));
doReturn(dummyTimeoutMessage).when(exception).getMessage();
doReturn(indexedTypes).when(fieldMappingTypeService).getFieldTypes(eq(client), eq(fieldName), eq(indexName));
try {
sut.queryIndex(searchRequest);
} catch (AppException e) {
int errorCode = 504;
String errorMessage = "Request timed out after waiting for 1m";
validateAppException(e, errorCode, errorMessage);
throw (e);
}
}
@Test(expected = AppException.class)
public void testQueryBase_IOException_EmptyMessage_throwsException() throws IOException {
IOException exception = mock(IOException.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment