Rest Client - Precondition RunTimeException - JDK 17

(relevant - OpenSearch):

Describe: In porting to JDK 17 (error does not occur up thru JDK16), I am receiving a runtime outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length) exception from jdk.internal.util,Preconditions class. This only occurs once (initially) when creating a new index. The example OpenSearch code from the highlevelrest client below triggers the error on the low level client.

Configuration: OpenSearch 2.6, SprintBootStarterWeb 3.0.6 (occurs on 2.x versions as well) - JDK17 and above

Example Code:

lowLevelRestClient = restClient.getLowLevelClient();

NodesSniffer nodesniffer = new OpenSearchNodesSniffer(

Sniffer sniffer = Sniffer.builder(lowLevelRestClient)

SniffOnFailureListener listener = new SniffOnFailureListener();

CreateIndexRequest createIndexRequest = new CreateIndexRequest(“test-my”);
.put(“index.number_of_shards”, 1)
.put(“index.number_of_replicas”, 0)

		try {
			HashMap<String, String> typeMapping = new HashMap<String, String>();
			typeMapping.put("type", "integer");
			HashMap<String, Object> ageMapping = new HashMap<String, Object>();
			ageMapping.put("age", typeMapping);
			HashMap<String, Object> mapping = new HashMap<String, Object>();
			mapping.put("properties", ageMapping);
			CreateIndexResponse createIndexResponse = restClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);
			System.out.println("\nCreating index:");
			System.out.println("Is client acknowledged?" + ((createIndexResponse.isAcknowledged()) ? " Yes" : " No"));
		} catch (Exception e) {

We can work around this problem, so its not a high priority for us. Planning to convert to Java Client at 3.0 release.


I’m curious, what is the motivation for converting to Java Client at 3.0 release but not sooner?

We have not verified all of our High Level Rest (HLR) api usage and related aggregation code can be ported directly. HLR works for and there is no need to take on an uncertain project until required, which will be on or about the 3.0 release

Generic Rest Client

Will the current High Level Rest Client be deprecated in 3.0 before a generic REST client (Issue #417) is available? Our code utilizes JSON exclusively (versus Java Classes), allowing us to specify the specific fields to return in a search query.

@docme The plan (for now as per [1]) is to deprecate REST clients in 3.0.0 and remove them in 4.0.0, thank you

[1] [META] Deprecate REST client · Issue #5424 · opensearch-project/OpenSearch · GitHub

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.