Skip to content

Commit af87b45

Browse files
authored
Merge branch 'main' into 2025/07/08/http-connection-metrics
2 parents d589c5b + ecbc360 commit af87b45

File tree

119 files changed

+689
-673
lines changed

Some content is hidden

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

119 files changed

+689
-673
lines changed

build-tools-internal/src/main/resources/forbidden/es-all-signatures.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ java.nio.channels.SocketChannel#connect(java.net.SocketAddress)
3535
# org.elasticsearch.core.Booleans#parseBoolean(java.lang.String) directly on the string.
3636
@defaultMessage use org.elasticsearch.core.Booleans#parseBoolean(java.lang.String)
3737
java.lang.Boolean#getBoolean(java.lang.String)
38+
java.lang.Boolean#parseBoolean(java.lang.String)
39+
java.lang.Boolean#valueOf(java.lang.String)
3840

3941
org.apache.lucene.util.IOUtils @ use @org.elasticsearch.core.internal.io instead
4042

docs/changelog/129872.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 129872
2+
summary: Run `TransportClusterStateAction` on local node
3+
area: Distributed
4+
type: enhancement
5+
issues: []

libs/core/src/main/java/org/elasticsearch/core/Booleans.java

Lines changed: 4 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,16 @@ public static Boolean parseBoolean(String value, Boolean defaultValue) {
9797
}
9898

9999
/**
100-
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
100+
* Wrapper around Boolean.parseBoolean for lenient parsing of booleans.
101101
*
102-
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(String, Boolean)} instead.
102+
* Note: Lenient parsing is highly discouraged and should only be used if absolutely necessary.
103103
*/
104-
@Deprecated
105-
public static Boolean parseBooleanLenient(String value, Boolean defaultValue) {
106-
if (value == null) { // only for the null case we do that here!
107-
return defaultValue;
108-
}
109-
return parseBooleanLenient(value, false);
110-
}
111-
112-
/**
113-
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
114-
*
115-
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(String, boolean)} instead.
116-
*/
117-
@Deprecated
104+
@SuppressForbidden(reason = "allow lenient parsing of booleans")
118105
public static boolean parseBooleanLenient(String value, boolean defaultValue) {
119106
if (value == null) {
120107
return defaultValue;
121108
}
122-
return switch (value) {
123-
case "false", "0", "off", "no" -> false;
124-
default -> true;
125-
};
109+
return Boolean.parseBoolean(value);
126110
}
127111

128112
/**
@@ -138,71 +122,4 @@ public static boolean isFalse(String value) {
138122
public static boolean isTrue(String value) {
139123
return "true".equals(value);
140124
}
141-
142-
/**
143-
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
144-
*
145-
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(char[], int, int, boolean)} instead
146-
*/
147-
@Deprecated
148-
public static boolean parseBooleanLenient(char[] text, int offset, int length, boolean defaultValue) {
149-
if (text == null || length == 0) {
150-
return defaultValue;
151-
}
152-
if (length == 1) {
153-
return text[offset] != '0';
154-
}
155-
if (length == 2) {
156-
return (text[offset] == 'n' && text[offset + 1] == 'o') == false;
157-
}
158-
if (length == 3) {
159-
return (text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f') == false;
160-
}
161-
if (length == 5) {
162-
return (text[offset] == 'f'
163-
&& text[offset + 1] == 'a'
164-
&& text[offset + 2] == 'l'
165-
&& text[offset + 3] == 's'
166-
&& text[offset + 4] == 'e') == false;
167-
}
168-
return true;
169-
}
170-
171-
/**
172-
* returns true if the a sequence of chars is one of "true","false","on","off","yes","no","0","1"
173-
*
174-
* @param text sequence to check
175-
* @param offset offset to start
176-
* @param length length to check
177-
*
178-
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #isBoolean(char[], int, int)} instead.
179-
*/
180-
@Deprecated
181-
public static boolean isBooleanLenient(char[] text, int offset, int length) {
182-
if (text == null || length == 0) {
183-
return false;
184-
}
185-
if (length == 1) {
186-
return text[offset] == '0' || text[offset] == '1';
187-
}
188-
if (length == 2) {
189-
return (text[offset] == 'n' && text[offset + 1] == 'o') || (text[offset] == 'o' && text[offset + 1] == 'n');
190-
}
191-
if (length == 3) {
192-
return (text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f')
193-
|| (text[offset] == 'y' && text[offset + 1] == 'e' && text[offset + 2] == 's');
194-
}
195-
if (length == 4) {
196-
return (text[offset] == 't' && text[offset + 1] == 'r' && text[offset + 2] == 'u' && text[offset + 3] == 'e');
197-
}
198-
if (length == 5) {
199-
return (text[offset] == 'f'
200-
&& text[offset + 1] == 'a'
201-
&& text[offset + 2] == 'l'
202-
&& text[offset + 3] == 's'
203-
&& text[offset + 4] == 'e');
204-
}
205-
return false;
206-
}
207-
208125
}

libs/core/src/main/java/org/elasticsearch/core/internal/provider/EmbeddedImplClassLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.core.internal.provider;
1111

12+
import org.elasticsearch.core.Booleans;
13+
1214
import java.io.BufferedReader;
1315
import java.io.IOException;
1416
import java.io.InputStream;
@@ -469,7 +471,7 @@ private static boolean isMultiRelease(ClassLoader parent, String jarPrefix) thro
469471
try (InputStream is = parent.getResourceAsStream(jarPrefix + "/META-INF/MANIFEST.MF")) {
470472
if (is != null) {
471473
Manifest manifest = new Manifest(is);
472-
return Boolean.parseBoolean(manifest.getMainAttributes().getValue(MULTI_RELEASE));
474+
return Booleans.parseBooleanLenient(manifest.getMainAttributes().getValue(MULTI_RELEASE), false);
473475
}
474476
}
475477
return false;

libs/entitlement/tools/public-callers-finder/src/main/java/org/elasticsearch/entitlement/tools/publiccallersfinder/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package org.elasticsearch.entitlement.tools.publiccallersfinder;
1111

12+
import org.elasticsearch.core.Booleans;
1213
import org.elasticsearch.core.SuppressForbidden;
1314
import org.elasticsearch.entitlement.tools.ExternalAccess;
1415
import org.elasticsearch.entitlement.tools.Utils;
@@ -191,7 +192,7 @@ private static void parseCsv(Path csvPath, MethodDescriptorConsumer methodConsum
191192

192193
public static void main(String[] args) throws IOException {
193194
var csvFilePath = Path.of(args[0]);
194-
boolean bubbleUpFromPublic = args.length >= 2 && Boolean.parseBoolean(args[1]);
195+
boolean bubbleUpFromPublic = args.length >= 2 && Booleans.parseBoolean(args[1]);
195196
parseCsv(csvFilePath, (method, module, access) -> identifyTopLevelEntryPoints(method, module, access, bubbleUpFromPublic));
196197
}
197198
}

libs/native/src/main/java/org/elasticsearch/nativeaccess/PosixNativeAccess.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ static boolean isMacOrLinuxAarch64() {
220220
/** -Dorg.elasticsearch.nativeaccess.enableVectorLibrary=false to disable.*/
221221
static final String ENABLE_JDK_VECTOR_LIBRARY = "org.elasticsearch.nativeaccess.enableVectorLibrary";
222222

223+
@SuppressForbidden(
224+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
225+
)
223226
static boolean checkEnableSystemProperty() {
224227
return Optional.ofNullable(System.getProperty(ENABLE_JDK_VECTOR_LIBRARY)).map(Boolean::valueOf).orElse(Boolean.TRUE);
225228
}

modules/aggregations/src/yamlRestTest/java/org/elasticsearch/aggregations/AggregationsClientYamlTestSuiteIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.carrotsearch.randomizedtesting.annotations.Name;
1212
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1313

14+
import org.elasticsearch.core.Booleans;
1415
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1516
import org.elasticsearch.test.cluster.FeatureFlag;
1617
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
@@ -26,8 +27,8 @@ private static ElasticsearchCluster makeCluster() {
2627

2728
// On Serverless, we want to disallow scripted metrics aggs per default.
2829
// The following override allows us to still run the scripted metrics agg tests without breaking bwc.
29-
boolean disableAllowListPerDefault = Boolean.parseBoolean(
30-
System.getProperty("tests.disable_scripted_metric_allow_list_per_default")
30+
boolean disableAllowListPerDefault = Booleans.parseBoolean(
31+
System.getProperty("tests.disable_scripted_metric_allow_list_per_default", "false")
3132
);
3233
if (disableAllowListPerDefault) {
3334
return cluster.setting("search.aggs.only_allowed_metric_scripts", "false").build();

modules/data-streams/src/yamlRestTest/java/org/elasticsearch/datastreams/DataStreamsClientYamlTestSuiteIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.common.settings.SecureString;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.common.util.concurrent.ThreadContext;
16+
import org.elasticsearch.core.Booleans;
1617
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1718
import org.elasticsearch.test.cluster.FeatureFlag;
1819
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
@@ -53,7 +54,7 @@ private static ElasticsearchCluster createCluster() {
5354
if (initTestSeed().nextBoolean()) {
5455
clusterBuilder.setting("xpack.license.self_generated.type", "trial");
5556
}
56-
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
57+
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
5758
if (setNodes) {
5859
clusterBuilder.nodes(2);
5960
}

modules/dot-prefix-validation/src/yamlRestTest/java/org/elasticsearch/validation/DotPrefixClientYamlTestSuiteIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.common.settings.SecureString;
1515
import org.elasticsearch.common.settings.Settings;
1616
import org.elasticsearch.common.util.concurrent.ThreadContext;
17+
import org.elasticsearch.core.Booleans;
1718
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1819
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
1920
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@@ -50,7 +51,7 @@ private static ElasticsearchCluster createCluster() {
5051
.setting("xpack.security.enabled", "true")
5152
.keystore("bootstrap.password", "x-pack-test-password")
5253
.user("x_pack_rest_user", "x-pack-test-password");
53-
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
54+
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
5455
if (setNodes) {
5556
clusterBuilder.nodes(2);
5657
}

modules/ingest-common/src/yamlRestTest/java/org/elasticsearch/ingest/common/IngestCommonClientYamlTestSuiteIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.settings.SecureString;
1616
import org.elasticsearch.common.settings.Settings;
1717
import org.elasticsearch.common.util.concurrent.ThreadContext;
18+
import org.elasticsearch.core.Booleans;
1819
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1920
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
2021
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@@ -48,7 +49,7 @@ private static ElasticsearchCluster createCluster() {
4849
.distribution(DistributionType.DEFAULT)
4950
.setting("xpack.security.enabled", "true")
5051
.user("x_pack_rest_user", "x-pack-test-password");
51-
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
52+
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
5253
if (setNodes) {
5354
clusterBuilder.nodes(2);
5455
}

0 commit comments

Comments
 (0)