Skip to content

Commit f370f25

Browse files
authored
Merge branch 'main' into delegate-builds-to-gradle
2 parents 6037026 + f3c4f51 commit f370f25

File tree

216 files changed

+3113
-1325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+3113
-1325
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/index/codec/tsdb/TSDBDocValuesMergeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import java.util.concurrent.Executors;
5656
import java.util.concurrent.TimeUnit;
5757

58-
@BenchmarkMode(Mode.SampleTime)
58+
@BenchmarkMode(Mode.SingleShotTime)
5959
@OutputTimeUnit(TimeUnit.MILLISECONDS)
6060
@State(Scope.Benchmark)
6161
@Fork(1)

branches.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
{
55
"branch": "main"
66
},
7-
{
8-
"branch": "8.16"
9-
},
107
{
118
"branch": "9.0"
129
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal.dependencies.patches.awsv2sdk;
11+
12+
import org.elasticsearch.gradle.internal.dependencies.patches.PatcherInfo;
13+
import org.elasticsearch.gradle.internal.dependencies.patches.Utils;
14+
import org.gradle.api.artifacts.transform.CacheableTransform;
15+
import org.gradle.api.artifacts.transform.InputArtifact;
16+
import org.gradle.api.artifacts.transform.TransformAction;
17+
import org.gradle.api.artifacts.transform.TransformOutputs;
18+
import org.gradle.api.artifacts.transform.TransformParameters;
19+
import org.gradle.api.file.FileSystemLocation;
20+
import org.gradle.api.provider.Provider;
21+
import org.gradle.api.tasks.Classpath;
22+
import org.jetbrains.annotations.NotNull;
23+
24+
import java.io.File;
25+
import java.util.List;
26+
27+
import static org.elasticsearch.gradle.internal.dependencies.patches.PatcherInfo.classPatcher;
28+
29+
@CacheableTransform
30+
public abstract class Awsv2ClassPatcher implements TransformAction<TransformParameters.None> {
31+
32+
private static final String JAR_FILE_TO_PATCH = "aws-query-protocol";
33+
34+
private static final List<PatcherInfo> CLASS_PATCHERS = List.of(
35+
// This patcher is needed because of this AWS bug: https://github.com/aws/aws-sdk-java-v2/issues/5968
36+
// As soon as the bug is resolved and we upgrade our AWS SDK v2 libraries, we can remove this.
37+
classPatcher(
38+
"software/amazon/awssdk/protocols/query/internal/marshall/ListQueryMarshaller.class",
39+
"213e84d9a745bdae4b844334d17aecdd6499b36df32aa73f82dc114b35043009",
40+
StringFormatInPathResolverPatcher::new
41+
)
42+
);
43+
44+
@Classpath
45+
@InputArtifact
46+
public abstract Provider<FileSystemLocation> getInputArtifact();
47+
48+
@Override
49+
public void transform(@NotNull TransformOutputs outputs) {
50+
File inputFile = getInputArtifact().get().getAsFile();
51+
52+
if (inputFile.getName().startsWith(JAR_FILE_TO_PATCH)) {
53+
System.out.println("Patching " + inputFile.getName());
54+
File outputFile = outputs.file(inputFile.getName().replace(".jar", "-patched.jar"));
55+
Utils.patchJar(inputFile, outputFile, CLASS_PATCHERS);
56+
} else {
57+
System.out.println("Skipping " + inputFile.getName());
58+
outputs.file(getInputArtifact());
59+
}
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal.dependencies.patches.awsv2sdk;
11+
12+
import org.objectweb.asm.ClassVisitor;
13+
import org.objectweb.asm.ClassWriter;
14+
import org.objectweb.asm.MethodVisitor;
15+
import org.objectweb.asm.Type;
16+
17+
import java.util.Locale;
18+
19+
import static org.objectweb.asm.Opcodes.ASM9;
20+
import static org.objectweb.asm.Opcodes.GETSTATIC;
21+
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
22+
23+
class StringFormatInPathResolverPatcher extends ClassVisitor {
24+
25+
StringFormatInPathResolverPatcher(ClassWriter classWriter) {
26+
super(ASM9, classWriter);
27+
}
28+
29+
@Override
30+
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
31+
return new ReplaceCallMethodVisitor(super.visitMethod(access, name, descriptor, signature, exceptions));
32+
}
33+
34+
/**
35+
* Replaces calls to String.format(format, args); with calls to String.format(Locale.ROOT, format, args);
36+
*/
37+
private static class ReplaceCallMethodVisitor extends MethodVisitor {
38+
private static final String CLASS_INTERNAL_NAME = Type.getInternalName(String.class);
39+
private static final String METHOD_NAME = "format";
40+
private static final String OLD_METHOD_DESCRIPTOR = Type.getMethodDescriptor(
41+
Type.getType(String.class),
42+
Type.getType(String.class),
43+
Type.getType(Object[].class)
44+
);
45+
private static final String NEW_METHOD_DESCRIPTOR = Type.getMethodDescriptor(
46+
Type.getType(String.class),
47+
Type.getType(Locale.class),
48+
Type.getType(String.class),
49+
Type.getType(Object[].class)
50+
);
51+
52+
private boolean foundFormatPattern = false;
53+
54+
ReplaceCallMethodVisitor(MethodVisitor methodVisitor) {
55+
super(ASM9, methodVisitor);
56+
}
57+
58+
@Override
59+
public void visitLdcInsn(Object value) {
60+
if (value instanceof String s && s.startsWith("%s")) {
61+
if (foundFormatPattern) {
62+
throw new IllegalStateException(
63+
"A previous string format constant was not paired with a String.format() call. "
64+
+ "Patching would generate an unbalances stack"
65+
);
66+
}
67+
// Push the extra arg on the stack
68+
mv.visitFieldInsn(GETSTATIC, Type.getInternalName(Locale.class), "ROOT", Type.getDescriptor(Locale.class));
69+
foundFormatPattern = true;
70+
}
71+
super.visitLdcInsn(value);
72+
}
73+
74+
@Override
75+
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
76+
if (opcode == INVOKESTATIC
77+
&& foundFormatPattern
78+
&& CLASS_INTERNAL_NAME.equals(owner)
79+
&& METHOD_NAME.equals(name)
80+
&& OLD_METHOD_DESCRIPTOR.equals(descriptor)) {
81+
// Replace the call with String.format(Locale.ROOT, format, args)
82+
mv.visitMethodInsn(INVOKESTATIC, CLASS_INTERNAL_NAME, METHOD_NAME, NEW_METHOD_DESCRIPTOR, false);
83+
foundFormatPattern = false;
84+
} else {
85+
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
86+
}
87+
}
88+
}
89+
}

build-tools-internal/version.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ junit = 4.13.2
4141
junit5 = 5.12.1
4242
hamcrest = 3.0
4343
mocksocket = 1.2
44+
apache_mina = 2.2.4
4445

4546
# test container dependencies
4647
testcontainer = 1.19.2

distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommand.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
import org.elasticsearch.core.CheckedFunction;
2020
import org.elasticsearch.env.Environment;
2121

22-
import java.io.BufferedReader;
2322
import java.io.CharArrayWriter;
2423
import java.io.Closeable;
2524
import java.io.IOException;
26-
import java.io.InputStream;
27-
import java.io.InputStreamReader;
28-
import java.nio.charset.StandardCharsets;
25+
import java.io.Reader;
2926
import java.util.Arrays;
3027
import java.util.List;
3128

@@ -47,11 +44,6 @@ class AddStringKeyStoreCommand extends BaseKeyStoreCommand {
4744
this.arguments = parser.nonOptions("setting names");
4845
}
4946

50-
// pkg private so tests can manipulate
51-
InputStream getStdin() {
52-
return System.in;
53-
}
54-
5547
@Override
5648
protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {
5749
final List<String> settings = arguments.values(options);
@@ -64,7 +56,7 @@ protected void executeCommand(Terminal terminal, OptionSet options, Environment
6456
final Closeable closeable;
6557
final CheckedFunction<String, char[], IOException> valueSupplier;
6658
if (options.has(stdinOption)) {
67-
final BufferedReader stdinReader = new BufferedReader(new InputStreamReader(getStdin(), StandardCharsets.UTF_8));
59+
final Reader stdinReader = terminal.getReader();
6860
valueSupplier = s -> {
6961
try (CharArrayWriter writer = new CharArrayWriter()) {
7062
int c;

distribution/tools/keystore-cli/src/test/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommandTests.java

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,20 @@
1818
import org.elasticsearch.common.settings.KeyStoreWrapper;
1919
import org.elasticsearch.env.Environment;
2020

21-
import java.io.ByteArrayInputStream;
2221
import java.io.CharArrayWriter;
23-
import java.io.InputStream;
24-
import java.nio.charset.StandardCharsets;
2522

2623
import static org.hamcrest.Matchers.anyOf;
2724
import static org.hamcrest.Matchers.containsString;
2825
import static org.hamcrest.Matchers.hasToString;
2926

3027
public class AddStringKeyStoreCommandTests extends KeyStoreCommandTestCase {
31-
InputStream input;
32-
3328
@Override
3429
protected Command newCommand() {
3530
return new AddStringKeyStoreCommand() {
3631
@Override
3732
protected Environment createEnv(OptionSet options, ProcessInfo processInfo) throws UserException {
3833
return env;
3934
}
40-
41-
@Override
42-
InputStream getStdin() {
43-
return input;
44-
}
4535
};
4636
}
4737

@@ -167,7 +157,7 @@ public void testStdinShort() throws Exception {
167157
String password = "keystorepassword";
168158
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
169159
terminal.addSecretInput(password);
170-
setInput("secret value 1");
160+
terminal.addSecretInput("secret value 1");
171161
execute("-x", "foo");
172162
assertSecureString("foo", "secret value 1", password);
173163
}
@@ -176,7 +166,7 @@ public void testStdinLong() throws Exception {
176166
String password = "keystorepassword";
177167
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
178168
terminal.addSecretInput(password);
179-
setInput("secret value 2");
169+
terminal.addSecretInput("secret value 2");
180170
execute("--stdin", "foo");
181171
assertSecureString("foo", "secret value 2", password);
182172
}
@@ -185,7 +175,7 @@ public void testStdinNoInput() throws Exception {
185175
String password = "keystorepassword";
186176
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
187177
terminal.addSecretInput(password);
188-
setInput("");
178+
terminal.addSecretInput("");
189179
execute("-x", "foo");
190180
assertSecureString("foo", "", password);
191181
}
@@ -194,7 +184,7 @@ public void testStdinInputWithLineBreaks() throws Exception {
194184
String password = "keystorepassword";
195185
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
196186
terminal.addSecretInput(password);
197-
setInput("Typedthisandhitenter\n");
187+
terminal.addSecretInput("Typedthisandhitenter\n");
198188
execute("-x", "foo");
199189
assertSecureString("foo", "Typedthisandhitenter", password);
200190
}
@@ -203,7 +193,7 @@ public void testStdinInputWithCarriageReturn() throws Exception {
203193
String password = "keystorepassword";
204194
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
205195
terminal.addSecretInput(password);
206-
setInput("Typedthisandhitenter\r");
196+
terminal.addSecretInput("Typedthisandhitenter\r");
207197
execute("-x", "foo");
208198
assertSecureString("foo", "Typedthisandhitenter", password);
209199
}
@@ -212,7 +202,9 @@ public void testStdinWithMultipleValues() throws Exception {
212202
final String password = "keystorepassword";
213203
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
214204
terminal.addSecretInput(password);
215-
setInput("bar1\nbar2\nbar3");
205+
terminal.addSecretInput("bar1");
206+
terminal.addSecretInput("bar2");
207+
terminal.addSecretInput("bar3");
216208
execute(randomFrom("-x", "--stdin"), "foo1", "foo2", "foo3");
217209
assertSecureString("foo1", "bar1", password);
218210
assertSecureString("foo2", "bar2", password);
@@ -228,7 +220,7 @@ public void testAddUtf8String() throws Exception {
228220
for (int i = 0; i < stringSize; i++) {
229221
secretChars.write((char) randomIntBetween(129, 2048));
230222
}
231-
setInput(secretChars.toString());
223+
terminal.addSecretInput(secretChars.toString());
232224
execute("-x", "foo");
233225
assertSecureString("foo", secretChars.toString(), password);
234226
}
@@ -265,8 +257,4 @@ public void testAddToUnprotectedKeystore() throws Exception {
265257
execute("foo");
266258
assertSecureString("foo", "bar", password);
267259
}
268-
269-
void setInput(String inputStr) {
270-
input = new ByteArrayInputStream(inputStr.getBytes(StandardCharsets.UTF_8));
271-
}
272260
}

docs/changelog/125517.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 125517
2+
summary: Semantic Text Chunking Indexing Pressure
3+
area: Machine Learning
4+
type: enhancement
5+
issues: []

docs/changelog/126372.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 126372
2+
summary: Add `IndexingPressureMonitor` to monitor large indexing operations
3+
area: CRUD
4+
type: enhancement
5+
issues: []

docs/changelog/126687.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126687
2+
summary: Permit at+jwt typ header value in jwt access tokens
3+
area: Authentication
4+
type: enhancement
5+
issues:
6+
- 119370

0 commit comments

Comments
 (0)