> toPass = new ArrayList<>(items);
items.clear();
- handler.lastItems(toPass, () -> Releasables.close(releasables), new RestRefCountedChunkedToXContentListener<>(channel));
+ handler.lastItems(toPass, () -> Releasables.close(releasables), createResponseListener(channel));
}
handler.updateWaitForChunkMetrics(TimeUnit.NANOSECONDS.toMillis(totalChunkWaitTimeInNanos));
totalChunkWaitTimeInNanos = 0L;
@@ -282,7 +301,7 @@ public void streamClose() {
private void shortCircuit() {
shortCircuited = true;
- Releasables.close(handler);
+ Releasables.close(parser, handler);
Releasables.close(unParsedChunks);
unParsedChunks.clear();
}
diff --git a/server/src/main/resources/org/elasticsearch/bootstrap/security.policy b/server/src/main/resources/org/elasticsearch/bootstrap/security.policy
index 55abdc84fc8fb..17c682319c98f 100644
--- a/server/src/main/resources/org/elasticsearch/bootstrap/security.policy
+++ b/server/src/main/resources/org/elasticsearch/bootstrap/security.policy
@@ -73,6 +73,7 @@ grant codeBase "${codebase.elasticsearch-simdvec}" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
+
//// Everything else:
grant {
diff --git a/x-pack/plugin/esql/arrow/build.gradle b/x-pack/plugin/esql/arrow/build.gradle
index d6fa48982d029..9f96e26cfbd98 100644
--- a/x-pack/plugin/esql/arrow/build.gradle
+++ b/x-pack/plugin/esql/arrow/build.gradle
@@ -12,40 +12,7 @@ dependencies {
compileOnly project(':x-pack:plugin:esql:compute')
compileOnly project(':x-pack:plugin:esql-core')
compileOnly project(':x-pack:plugin:mapper-version')
- implementation('org.apache.arrow:arrow-vector:18.3.0')
- implementation('org.apache.arrow:arrow-format:18.3.0')
- implementation('org.apache.arrow:arrow-memory-core:18.3.0')
- implementation('org.checkerframework:checker-qual:3.42.0')
- implementation('com.google.flatbuffers:flatbuffers-java:23.5.26')
- // Needed for the json arrow serialization, and loaded even if we don't use it.
- implementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
- implementation("com.fasterxml.jackson.core:jackson-core:${versions.jackson}")
- implementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
- implementation("org.slf4j:slf4j-api:${versions.slf4j}")
- runtimeOnly "org.slf4j:slf4j-nop:${versions.slf4j}"
+ implementation(project(":libs:arrow"))
testImplementation project(':test:framework')
- testImplementation('org.apache.arrow:arrow-memory-unsafe:18.3.0')
- testImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}")
-}
-
-tasks.named("dependencyLicenses").configure {
- mapping from: /jackson-.*/, to: 'jackson'
- mapping from: /arrow-.*/, to: 'arrow'
- mapping from: /slf4j-.*/, to: 'slf4j'
-}
-
-tasks.named("thirdPartyAudit").configure {
- ignoreViolations(
- // uses sun.misc.Unsafe. Only used in tests.
- 'org.apache.arrow.memory.util.MemoryUtil',
- 'org.apache.arrow.memory.util.MemoryUtil$1',
- )
- ignoreMissingClasses(
- 'org.apache.commons.codec.binary.Hex'
- )
-}
-
-tasks.named("test").configure {
- jvmArgs('--add-opens=java.base/java.nio=ALL-UNNAMED')
}
diff --git a/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/AllocationManagerShim.java b/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/AllocationManagerShim.java
deleted file mode 100644
index b52d1053ff595..0000000000000
--- a/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/AllocationManagerShim.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-package org.elasticsearch.xpack.esql.arrow;
-
-import org.apache.arrow.memory.AllocationManager;
-import org.apache.arrow.memory.ArrowBuf;
-import org.apache.arrow.memory.BufferAllocator;
-import org.apache.arrow.memory.DefaultAllocationManagerOption;
-import org.elasticsearch.core.SuppressForbidden;
-import org.elasticsearch.logging.LogManager;
-import org.elasticsearch.logging.Logger;
-
-import java.lang.reflect.Field;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * An Arrow memory allocation manager that always fails.
- *
- * We don't actually use Arrow's memory manager as we stream dataframe buffers directly from ESQL blocks.
- * But Arrow won't initialize properly unless it has one (and requires either the arrow-memory-netty or arrow-memory-unsafe libraries).
- * It also does some fancy classpath scanning and calls to {@code setAccessible} which will be rejected by the security manager.
- *
- * So we configure an allocation manager that will fail on any attempt to allocate memory.
- *
- * @see DefaultAllocationManagerOption
- */
-public class AllocationManagerShim implements AllocationManager.Factory {
-
- private static final Logger logger = LogManager.getLogger(AllocationManagerShim.class);
-
- /**
- * Initialize the Arrow memory allocation manager shim.
- */
- @SuppressForbidden(reason = "Inject the default Arrow memory allocation manager")
- public static void init() {
- try {
- Class.forName("org.elasticsearch.test.ESTestCase");
- logger.info("We're in tests, not disabling Arrow memory manager so we can use a real runtime for testing");
- } catch (ClassNotFoundException notfound) {
- logger.debug("Disabling Arrow's allocation manager");
- AccessController.doPrivileged((PrivilegedAction) () -> {
- try {
- Field field = DefaultAllocationManagerOption.class.getDeclaredField("DEFAULT_ALLOCATION_MANAGER_FACTORY");
- field.setAccessible(true);
- field.set(null, new AllocationManagerShim());
- } catch (Exception e) {
- throw new AssertionError("Can't init Arrow", e);
- }
- return null;
- });
- }
- }
-
- @Override
- public AllocationManager create(BufferAllocator accountingAllocator, long size) {
- throw new UnsupportedOperationException("Arrow memory manager is disabled");
- }
-
- @Override
- public ArrowBuf empty() {
- throw new UnsupportedOperationException("Arrow memory manager is disabled");
- }
-}
diff --git a/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/ArrowResponse.java b/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/ArrowResponse.java
index 208d3308d508b..0c02e0e698a7b 100644
--- a/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/ArrowResponse.java
+++ b/x-pack/plugin/esql/arrow/src/main/java/org/elasticsearch/xpack/esql/arrow/ArrowResponse.java
@@ -128,11 +128,6 @@ public void close() {
* the schema header, the data buffers, and the trailer.
*/
protected abstract static class ResponseSegment {
- static {
- // Init the Arrow memory manager shim
- AllocationManagerShim.init();
- }
-
protected final ArrowResponse response;
ResponseSegment(ArrowResponse response) {
diff --git a/x-pack/plugin/esql/qa/server/single-node/build.gradle b/x-pack/plugin/esql/qa/server/single-node/build.gradle
index ce962ef4c7e74..f34c67bea97e7 100644
--- a/x-pack/plugin/esql/qa/server/single-node/build.gradle
+++ b/x-pack/plugin/esql/qa/server/single-node/build.gradle
@@ -13,21 +13,10 @@ dependencies {
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
javaRestTestImplementation project(xpackModule('esql:qa:server'))
javaRestTestImplementation project(xpackModule('esql:tools'))
+ javaRestTestImplementation project(":libs:arrow")
javaRestTestImplementation project(xpackModule('esql'))
yamlRestTestImplementation project(xpackModule('esql:qa:server'))
- javaRestTestImplementation('org.apache.arrow:arrow-vector:18.3.0')
- javaRestTestImplementation('org.apache.arrow:arrow-format:18.3.0')
- javaRestTestImplementation('org.apache.arrow:arrow-memory-core:18.3.0')
- javaRestTestImplementation('org.checkerframework:checker-qual:3.42.0')
- javaRestTestImplementation('com.google.flatbuffers:flatbuffers-java:23.5.26')
- javaRestTestImplementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
- javaRestTestImplementation("com.fasterxml.jackson.core:jackson-core:${versions.jackson}")
- javaRestTestImplementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
- javaRestTestImplementation("org.slf4j:slf4j-api:${versions.slf4j}")
- javaRestTestImplementation("org.slf4j:slf4j-nop:${versions.slf4j}")
- javaRestTestImplementation('org.apache.arrow:arrow-memory-unsafe:18.3.0')
-
clusterPlugins project(':plugins:mapper-size')
clusterPlugins project(':plugins:mapper-murmur3')
clusterPlugins project(':x-pack:plugin:inference:qa:test-service-plugin')
@@ -45,7 +34,6 @@ restResources {
tasks.named('javaRestTest') {
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
- jvmArgs('--add-opens=java.base/java.nio=ALL-UNNAMED')
}
tasks.named('yamlRestTest') {
diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/sagemaker/schema/TaskAndApi.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/sagemaker/schema/TaskAndApi.java
index fa258c3275283..87e336e1e8778 100644
--- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/sagemaker/schema/TaskAndApi.java
+++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/sagemaker/schema/TaskAndApi.java
@@ -1,3 +1,4 @@
+
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License