Add Boolean#parseBoolean and Boolean.valueOf to forbidden-apis (#129684)

In a follow up (#128993) remaining lenient usage of booleans will be deprecated, to eventually remove everything except for a few places requiring lenient parsing by means of Booleans.parseBooleanLenient - which is a wrapper around Boolean.parseBoolean.
---------

Co-authored-by: Moritz Mack <mmack@apache.org>
This commit is contained in:
kvanerum 2025-07-08 14:09:10 +02:00 committed by GitHub
parent a16822df85
commit ac9bef6435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
67 changed files with 211 additions and 214 deletions

View File

@ -35,6 +35,8 @@ java.nio.channels.SocketChannel#connect(java.net.SocketAddress)
# org.elasticsearch.core.Booleans#parseBoolean(java.lang.String) directly on the string.
@defaultMessage use org.elasticsearch.core.Booleans#parseBoolean(java.lang.String)
java.lang.Boolean#getBoolean(java.lang.String)
java.lang.Boolean#parseBoolean(java.lang.String)
java.lang.Boolean#valueOf(java.lang.String)
org.apache.lucene.util.IOUtils @ use @org.elasticsearch.core.internal.io instead

View File

@ -97,32 +97,16 @@ public final class Booleans {
}
/**
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
* Wrapper around Boolean.parseBoolean for lenient parsing of booleans.
*
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(String, Boolean)} instead.
* Note: Lenient parsing is highly discouraged and should only be used if absolutely necessary.
*/
@Deprecated
public static Boolean parseBooleanLenient(String value, Boolean defaultValue) {
if (value == null) { // only for the null case we do that here!
return defaultValue;
}
return parseBooleanLenient(value, false);
}
/**
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
*
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(String, boolean)} instead.
*/
@Deprecated
@SuppressForbidden(reason = "allow lenient parsing of booleans")
public static boolean parseBooleanLenient(String value, boolean defaultValue) {
if (value == null) {
return defaultValue;
}
return switch (value) {
case "false", "0", "off", "no" -> false;
default -> true;
};
return Boolean.parseBoolean(value);
}
/**
@ -138,71 +122,4 @@ public final class Booleans {
public static boolean isTrue(String value) {
return "true".equals(value);
}
/**
* Returns {@code false} if text is in "false", "0", "off", "no"; else, {@code true}.
*
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #parseBoolean(char[], int, int, boolean)} instead
*/
@Deprecated
public static boolean parseBooleanLenient(char[] text, int offset, int length, boolean defaultValue) {
if (text == null || length == 0) {
return defaultValue;
}
if (length == 1) {
return text[offset] != '0';
}
if (length == 2) {
return (text[offset] == 'n' && text[offset + 1] == 'o') == false;
}
if (length == 3) {
return (text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f') == false;
}
if (length == 5) {
return (text[offset] == 'f'
&& text[offset + 1] == 'a'
&& text[offset + 2] == 'l'
&& text[offset + 3] == 's'
&& text[offset + 4] == 'e') == false;
}
return true;
}
/**
* returns true if the a sequence of chars is one of "true","false","on","off","yes","no","0","1"
*
* @param text sequence to check
* @param offset offset to start
* @param length length to check
*
* @deprecated Only kept to provide automatic upgrades for pre 6.0 indices. Use {@link #isBoolean(char[], int, int)} instead.
*/
@Deprecated
public static boolean isBooleanLenient(char[] text, int offset, int length) {
if (text == null || length == 0) {
return false;
}
if (length == 1) {
return text[offset] == '0' || text[offset] == '1';
}
if (length == 2) {
return (text[offset] == 'n' && text[offset + 1] == 'o') || (text[offset] == 'o' && text[offset + 1] == 'n');
}
if (length == 3) {
return (text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f')
|| (text[offset] == 'y' && text[offset + 1] == 'e' && text[offset + 2] == 's');
}
if (length == 4) {
return (text[offset] == 't' && text[offset + 1] == 'r' && text[offset + 2] == 'u' && text[offset + 3] == 'e');
}
if (length == 5) {
return (text[offset] == 'f'
&& text[offset + 1] == 'a'
&& text[offset + 2] == 'l'
&& text[offset + 3] == 's'
&& text[offset + 4] == 'e');
}
return false;
}
}

View File

@ -9,6 +9,8 @@
package org.elasticsearch.core.internal.provider;
import org.elasticsearch.core.Booleans;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -469,7 +471,7 @@ public final class EmbeddedImplClassLoader extends SecureClassLoader {
try (InputStream is = parent.getResourceAsStream(jarPrefix + "/META-INF/MANIFEST.MF")) {
if (is != null) {
Manifest manifest = new Manifest(is);
return Boolean.parseBoolean(manifest.getMainAttributes().getValue(MULTI_RELEASE));
return Booleans.parseBooleanLenient(manifest.getMainAttributes().getValue(MULTI_RELEASE), false);
}
}
return false;

View File

@ -9,6 +9,7 @@
package org.elasticsearch.entitlement.tools.publiccallersfinder;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.entitlement.tools.ExternalAccess;
import org.elasticsearch.entitlement.tools.Utils;
@ -191,7 +192,7 @@ public class Main {
public static void main(String[] args) throws IOException {
var csvFilePath = Path.of(args[0]);
boolean bubbleUpFromPublic = args.length >= 2 && Boolean.parseBoolean(args[1]);
boolean bubbleUpFromPublic = args.length >= 2 && Booleans.parseBoolean(args[1]);
parseCsv(csvFilePath, (method, module, access) -> identifyTopLevelEntryPoints(method, module, access, bubbleUpFromPublic));
}
}

View File

@ -220,6 +220,9 @@ abstract class PosixNativeAccess extends AbstractNativeAccess {
/** -Dorg.elasticsearch.nativeaccess.enableVectorLibrary=false to disable.*/
static final String ENABLE_JDK_VECTOR_LIBRARY = "org.elasticsearch.nativeaccess.enableVectorLibrary";
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
static boolean checkEnableSystemProperty() {
return Optional.ofNullable(System.getProperty(ENABLE_JDK_VECTOR_LIBRARY)).map(Boolean::valueOf).orElse(Boolean.TRUE);
}

View File

@ -11,6 +11,7 @@ package org.elasticsearch.aggregations;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
@ -26,8 +27,8 @@ public class AggregationsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase
// On Serverless, we want to disallow scripted metrics aggs per default.
// The following override allows us to still run the scripted metrics agg tests without breaking bwc.
boolean disableAllowListPerDefault = Boolean.parseBoolean(
System.getProperty("tests.disable_scripted_metric_allow_list_per_default")
boolean disableAllowListPerDefault = Booleans.parseBoolean(
System.getProperty("tests.disable_scripted_metric_allow_list_per_default", "false")
);
if (disableAllowListPerDefault) {
return cluster.setting("search.aggs.only_allowed_metric_scripts", "false").build();

View File

@ -13,6 +13,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
@ -53,7 +54,7 @@ public class DataStreamsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase
if (initTestSeed().nextBoolean()) {
clusterBuilder.setting("xpack.license.self_generated.type", "trial");
}
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
if (setNodes) {
clusterBuilder.nodes(2);
}

View File

@ -14,6 +14,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@ -50,7 +51,7 @@ public class DotPrefixClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
.setting("xpack.security.enabled", "true")
.keystore("bootstrap.password", "x-pack-test-password")
.user("x_pack_rest_user", "x-pack-test-password");
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
if (setNodes) {
clusterBuilder.nodes(2);
}

View File

@ -15,6 +15,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@ -48,7 +49,7 @@ public class IngestCommonClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase
.distribution(DistributionType.DEFAULT)
.setting("xpack.security.enabled", "true")
.user("x_pack_rest_user", "x-pack-test-password");
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
if (setNodes) {
clusterBuilder.nodes(2);
}

View File

@ -20,6 +20,7 @@ import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
@ -52,7 +53,7 @@ public class GeoIpReindexedIT extends ParameterizedFullClusterRestartTestCase {
// e.g. use ./gradlew -Dtests.jvm.argline="-Dgeoip_test_with_security=false" ":modules:ingest-geoip:qa:full-cluster-restart:check"
// to set this to false, if you so desire
private static final boolean useSecurity = Boolean.parseBoolean(System.getProperty("geoip_test_with_security", "true"));
private static final boolean useSecurity = Booleans.parseBoolean(System.getProperty("geoip_test_with_security", "true"));
private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)

View File

@ -21,6 +21,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.SizeLimitingStringWriter;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.MemorySizeValue;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.script.GeneralScriptException;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
@ -107,12 +108,19 @@ public final class MustacheScriptEngine implements ScriptEngine {
}
if (options.containsKey(DETECT_MISSING_PARAMS_OPTION)) {
builder.detectMissingParams(Boolean.valueOf(options.get(DETECT_MISSING_PARAMS_OPTION)));
builder.detectMissingParams(getDetectMissingParamsOption(options));
}
return builder.build();
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean getDetectMissingParamsOption(Map<String, String> options) {
return Boolean.valueOf(options.get(DETECT_MISSING_PARAMS_OPTION));
}
@Override
public String getType() {
return NAME;

View File

@ -11,6 +11,7 @@ package org.elasticsearch.painless;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.painless.Compiler.Loader;
import org.elasticsearch.painless.lookup.PainlessLookup;
import org.elasticsearch.painless.lookup.PainlessLookupBuilder;
@ -414,7 +415,7 @@ public final class PainlessScriptEngine implements ScriptEngine {
value = copy.remove(CompilerSettings.PICKY);
if (value != null) {
compilerSettings.setPicky(Boolean.parseBoolean(value));
compilerSettings.setPicky(parseBoolean(value));
}
value = copy.remove(CompilerSettings.INITIAL_CALL_SITE_DEPTH);
@ -439,6 +440,13 @@ public final class PainlessScriptEngine implements ScriptEngine {
return compilerSettings;
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean parseBoolean(String value) {
return Boolean.parseBoolean(value);
}
private static ScriptException convertToScriptException(String scriptSource, Throwable t) {
// create a script stack: this is just the script portion
List<String> scriptStack = new ArrayList<>();

View File

@ -26,6 +26,7 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.PageCacheRecycler;
import org.elasticsearch.core.Assertions;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.monitor.jvm.JvmInfo;
import java.util.Arrays;
@ -55,7 +56,7 @@ public class NettyAllocator {
+ ", factors={es.unsafe.use_netty_default_allocator=true}]";
} else {
final long heapSizeInBytes = JvmInfo.jvmInfo().getMem().getHeapMax().getBytes();
final boolean g1gcEnabled = Boolean.parseBoolean(JvmInfo.jvmInfo().useG1GC());
final boolean g1gcEnabled = useG1GC();
final long g1gcRegionSizeInBytes = JvmInfo.jvmInfo().getG1RegionSize();
final boolean g1gcRegionSizeIsKnown = g1gcRegionSizeInBytes != -1;
ByteSizeValue heapSize = ByteSizeValue.ofBytes(heapSizeInBytes);
@ -169,6 +170,13 @@ public class NettyAllocator {
};
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean useG1GC() {
return Boolean.parseBoolean(JvmInfo.jvmInfo().useG1GC());
}
public static void logAllocatorDescriptionIfNeeded() {
if (descriptionLogged.compareAndSet(false, true)) {
logger.info("creating NettyAllocator with the following configs: " + NettyAllocator.getAllocatorDescription());

View File

@ -21,6 +21,7 @@ import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.test.XContentTestUtils;
@ -330,7 +331,7 @@ public abstract class AbstractIndexCompatibilityTestCase extends ESRestTestCase
@SuppressWarnings("unchecked")
protected static void assertIndexSetting(String indexName, Setting<?> setting, Matcher<Boolean> matcher) throws Exception {
var indexSettings = getIndexSettingsAsMap(indexName);
assertThat(Boolean.parseBoolean((String) indexSettings.get(setting.getKey())), matcher);
assertThat(Booleans.parseBoolean((String) indexSettings.get(setting.getKey()), false), matcher);
}
protected static ResponseException expectUpdateIndexSettingsThrows(String indexName, Settings.Builder settings) {

View File

@ -26,6 +26,7 @@ import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.packaging.test.PackagingTestCase;
import java.io.IOException;
@ -82,7 +83,7 @@ public class ServerUtils {
.lines()
.filter(each -> each.startsWith("xpack.security.enabled"))
.findFirst()
.map(line -> Boolean.parseBoolean(line.split("=")[1]))
.map(line -> Booleans.parseBoolean(line.split("=")[1]))
// security is enabled by default, the only way for it to be disabled is to be explicitly disabled
.orElse(true);
}

View File

@ -29,7 +29,6 @@ public abstract class AbstractRollingTestCase extends ESRestTestCase {
}
protected static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.suite"));
protected static final boolean FIRST_MIXED_ROUND = Boolean.parseBoolean(System.getProperty("tests.first_round", "false"));
protected static final Version UPGRADE_FROM_VERSION = Version.fromString(System.getProperty("tests.upgrade_from_version"));
@Override

View File

@ -13,6 +13,7 @@ import com.carrotsearch.randomizedtesting.annotations.Name;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.indices.SystemIndices;
import org.elasticsearch.test.XContentTestUtils;
import org.junit.BeforeClass;
@ -33,7 +34,7 @@ public class FeatureUpgradeIT extends AbstractRollingUpgradeTestCase {
@BeforeClass
public static void ensureNotForwardCompatTest() {
assumeFalse("Only supported by bwc tests", Boolean.parseBoolean(System.getProperty("tests.fwc", "false")));
assumeFalse("Only supported by bwc tests", Booleans.parseBoolean(System.getProperty("tests.fwc", "false")));
}
public void testGetFeatureUpgradeStatus() throws Exception {

View File

@ -629,7 +629,7 @@ public class ResolveIndexAction extends ActionType<ResolveIndexAction.Response>
if (ia.isSystem()) {
attributes.add(Attribute.SYSTEM);
}
final boolean isFrozen = Boolean.parseBoolean(writeIndex.getSettings().get("index.frozen"));
final boolean isFrozen = writeIndex.getSettings().getAsBoolean("index.frozen", false);
if (isFrozen) {
attributes.add(Attribute.FROZEN);
}

View File

@ -11,6 +11,7 @@ package org.elasticsearch.cluster.metadata;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.SuppressForbidden;
import java.util.Collections;
import java.util.HashMap;
@ -111,7 +112,7 @@ public record LifecycleExecutionState(
}
String isAutoRetryableError = customData.get(IS_AUTO_RETRYABLE_ERROR);
if (isAutoRetryableError != null) {
builder.setIsAutoRetryableError(Boolean.parseBoolean(isAutoRetryableError));
builder.setIsAutoRetryableError(parseIsAutoRetryableError(isAutoRetryableError));
}
String failedStepRetryCount = customData.get(FAILED_STEP_RETRY_COUNT);
if (failedStepRetryCount != null) {
@ -204,6 +205,13 @@ public record LifecycleExecutionState(
return builder.build();
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean parseIsAutoRetryableError(String isAutoRetryableError) {
return Boolean.parseBoolean(isAutoRetryableError);
}
/**
* Converts this object to an immutable map representation for use with
* {@link IndexMetadata.Builder#putCustom(String, Map)}.

View File

@ -12,6 +12,7 @@ package org.elasticsearch.common.network;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Constants;
import org.elasticsearch.core.Predicates;
import org.elasticsearch.core.SuppressForbidden;
import java.io.IOException;
import java.net.Inet4Address;
@ -44,7 +45,14 @@ public abstract class NetworkUtils {
* @deprecated transition mechanism only
*/
@Deprecated
static final boolean PREFER_V6 = Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false"));
static final boolean PREFER_V6 = preferIPv6Addresses();
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean preferIPv6Addresses() {
return Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false"));
}
/**
* True if we can bind to a v6 address. Its silly, but for *binding* we have a need to know

View File

@ -69,6 +69,7 @@ import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Assertions;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.core.FixForMultiProject;
import org.elasticsearch.core.IOUtils;
@ -690,7 +691,7 @@ public class PersistedClusterStateService {
Long.parseLong(userData.get(LAST_ACCEPTED_VERSION_KEY)),
userData.get(NODE_ID_KEY),
userData.get(CLUSTER_UUID_KEY),
userData.get(CLUSTER_UUID_COMMITTED_KEY) != null ? Boolean.parseBoolean(userData.get(CLUSTER_UUID_COMMITTED_KEY)) : null
userData.get(CLUSTER_UUID_COMMITTED_KEY) != null ? Booleans.parseBoolean(userData.get(CLUSTER_UUID_COMMITTED_KEY)) : null
);
}

View File

@ -246,7 +246,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
mapperMetrics
);
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
boolean sourceOnly = Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only"));
boolean sourceOnly = indexSettings.getSettings().getAsBoolean("index.source_only", false);
if (indexSettings.getIndexSortConfig().hasIndexSort() && sourceOnly == false) {
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
// The sort order is validated right after the merge of the mapping later in the process.

View File

@ -25,6 +25,7 @@ import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.FeatureFlag;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.mapper.IgnoredSourceFieldMapper;
import org.elasticsearch.index.mapper.Mapper;
@ -305,7 +306,7 @@ public final class IndexSettings {
static class RefreshIntervalValidator implements Setting.Validator<TimeValue> {
static final String STATELESS_ALLOW_INDEX_REFRESH_INTERVAL_OVERRIDE = "es.stateless.allow.index.refresh_interval.override";
private static final boolean IS_OVERRIDE_ALLOWED = Boolean.parseBoolean(
private static final boolean IS_OVERRIDE_ALLOWED = Booleans.parseBoolean(
System.getProperty(STATELESS_ALLOW_INDEX_REFRESH_INTERVAL_OVERRIDE, "false")
);

View File

@ -13,6 +13,7 @@ import org.apache.lucene.codecs.DocValuesConsumer;
import org.apache.lucene.codecs.DocValuesProducer;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
import org.elasticsearch.core.SuppressForbidden;
import java.io.IOException;
@ -93,7 +94,14 @@ public class ES819TSDBDocValuesFormat extends org.apache.lucene.codecs.DocValues
static final String OPTIMIZED_MERGE_ENABLED_NAME = ES819TSDBDocValuesConsumer.class.getName() + ".enableOptimizedMerge";
static {
OPTIMIZED_MERGE_ENABLE_DEFAULT = Boolean.parseBoolean(System.getProperty(OPTIMIZED_MERGE_ENABLED_NAME, Boolean.TRUE.toString()));
OPTIMIZED_MERGE_ENABLE_DEFAULT = getOptimizedMergeEnabledDefault();
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean getOptimizedMergeEnabledDefault() {
return Boolean.parseBoolean(System.getProperty(OPTIMIZED_MERGE_ENABLED_NAME, Boolean.TRUE.toString()));
}
final int skipIndexIntervalSize;

View File

@ -26,6 +26,7 @@ import org.apache.lucene.codecs.hnsw.FlatVectorsWriter;
import org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsFormat;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.index.codec.vectors.OptimizedScalarQuantizer;
import java.io.IOException;
@ -87,7 +88,7 @@ import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.MAX_
*/
public class ES818BinaryQuantizedVectorsFormat extends FlatVectorsFormat {
public static final boolean USE_DIRECT_IO = Boolean.parseBoolean(System.getProperty("vector.rescoring.directio", "false"));
public static final boolean USE_DIRECT_IO = getUseDirectIO();
public static final String BINARIZED_VECTOR_COMPONENT = "BVEC";
public static final String NAME = "ES818BinaryQuantizedVectorsFormat";
@ -100,6 +101,13 @@ public class ES818BinaryQuantizedVectorsFormat extends FlatVectorsFormat {
static final String VECTOR_DATA_EXTENSION = "veb";
static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16;
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean getUseDirectIO() {
return Boolean.parseBoolean(System.getProperty("vector.rescoring.directio", "false"));
}
private static final FlatVectorsFormat rawVectorFormat = USE_DIRECT_IO
? new DirectIOLucene99FlatVectorsFormat(FlatVectorScorerUtil.getLucene99FlatVectorsScorer())
: new Lucene99FlatVectorsFormat(FlatVectorScorerUtil.getLucene99FlatVectorsScorer());

View File

@ -2736,7 +2736,7 @@ public class InternalEngine extends Engine {
}
// with tests.verbose, lucene sets this up: plumb to align with filesystem stream
private static final boolean TESTS_VERBOSE = Boolean.parseBoolean(System.getProperty("tests.verbose"));
private static final boolean TESTS_VERBOSE = Booleans.parseBoolean(System.getProperty("tests.verbose", "false"));
private static final boolean SHUFFLE_FORCE_MERGE = Booleans.parseBoolean(
System.getProperty("es.shuffle_forced_merge", Boolean.TRUE.toString())

View File

@ -12,6 +12,7 @@ package org.elasticsearch.index.store;
import org.apache.lucene.index.IndexFileNames;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.SuppressForbidden;
import java.util.Collections;
import java.util.Map;
@ -94,6 +95,9 @@ public enum LuceneFilesExtensions {
* that checks that all encountered file extensions are known to this class.
* In the future, we would like to add a proper plugin extension point for this.
*/
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean allowUnknownLuceneFileExtensions() {
return Boolean.parseBoolean(System.getProperty("es.allow_unknown_lucene_file_extensions", "false"));
}

View File

@ -12,6 +12,7 @@ package org.elasticsearch.indices.analysis.wrappers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.env.Environment;
import org.elasticsearch.plugin.settings.BooleanSetting;
import org.elasticsearch.plugin.settings.IntSetting;
@ -46,6 +47,9 @@ public class SettingsInvocationHandler implements InvocationHandler {
);
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
assert method.getAnnotations().length == 1;

View File

@ -55,6 +55,7 @@ import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNotFoundException;
@ -599,7 +600,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
) {
final boolean header;
if (version.onOrAfter(ERROR_TRACE_IN_TRANSPORT_HEADER) && threadPool.getThreadContext() != null) {
header = Boolean.parseBoolean(threadPool.getThreadContext().getHeaderOrDefault("error_trace", "false"));
header = getErrorTraceHeader(threadPool);
} else {
header = true;
}
@ -628,6 +629,13 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
});
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean getErrorTraceHeader(ThreadPool threadPool) {
return Boolean.parseBoolean(threadPool.getThreadContext().getHeaderOrDefault("error_trace", "false"));
}
public void executeDfsPhase(ShardSearchRequest request, SearchShardTask task, ActionListener<SearchPhaseResult> listener) {
listener = wrapListenerForErrorHandling(
listener,

View File

@ -12,10 +12,7 @@ package org.elasticsearch.common;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import java.util.Locale;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
public class BooleansTests extends ESTestCase {
private static final String[] NON_BOOLEANS = new String[] {
@ -87,56 +84,10 @@ public class BooleansTests extends ESTestCase {
}
}
public void testIsBooleanLenient() {
String[] booleans = new String[] { "true", "false", "on", "off", "yes", "no", "0", "1" };
String[] notBooleans = new String[] { "11", "00", "sdfsdfsf", "F", "T" };
assertThat(Booleans.isBooleanLenient(null, 0, 1), is(false));
for (String b : booleans) {
String t = "prefix" + b + "suffix";
assertTrue(
"failed to recognize [" + b + "] as boolean",
Booleans.isBooleanLenient(t.toCharArray(), "prefix".length(), b.length())
);
}
for (String nb : notBooleans) {
String t = "prefix" + nb + "suffix";
assertFalse("recognized [" + nb + "] as boolean", Booleans.isBooleanLenient(t.toCharArray(), "prefix".length(), nb.length()));
}
}
public void testParseBooleanLenient() {
assertThat(Booleans.parseBooleanLenient(randomFrom("true", "on", "yes", "1"), randomBoolean()), is(true));
assertThat(Booleans.parseBooleanLenient(randomFrom("false", "off", "no", "0"), randomBoolean()), is(false));
assertThat(Booleans.parseBooleanLenient(randomFrom("true", "on", "yes").toUpperCase(Locale.ROOT), randomBoolean()), is(true));
assertThat(Booleans.parseBooleanLenient(randomFrom("true", "TRUE", "True"), randomBoolean()), is(true));
assertThat(Booleans.parseBooleanLenient(randomFrom("false", "FALSE", "anything"), randomBoolean()), is(false));
assertThat(Booleans.parseBooleanLenient(null, false), is(false));
assertThat(Booleans.parseBooleanLenient(null, true), is(true));
assertThat(
Booleans.parseBooleanLenient(randomFrom("true", "on", "yes", "1"), randomFrom(Boolean.TRUE, Boolean.FALSE, null)),
is(true)
);
assertThat(
Booleans.parseBooleanLenient(randomFrom("false", "off", "no", "0"), randomFrom(Boolean.TRUE, Boolean.FALSE, null)),
is(false)
);
assertThat(
Booleans.parseBooleanLenient(
randomFrom("true", "on", "yes").toUpperCase(Locale.ROOT),
randomFrom(Boolean.TRUE, Boolean.FALSE, null)
),
is(true)
);
assertThat(Booleans.parseBooleanLenient(null, Boolean.FALSE), is(false));
assertThat(Booleans.parseBooleanLenient(null, Boolean.TRUE), is(true));
assertThat(Booleans.parseBooleanLenient(null, null), nullValue());
char[] chars = randomFrom("true", "on", "yes", "1").toCharArray();
assertThat(Booleans.parseBooleanLenient(chars, 0, chars.length, randomBoolean()), is(true));
chars = randomFrom("false", "off", "no", "0").toCharArray();
assertThat(Booleans.parseBooleanLenient(chars, 0, chars.length, randomBoolean()), is(false));
chars = randomFrom("true", "on", "yes").toUpperCase(Locale.ROOT).toCharArray();
assertThat(Booleans.parseBooleanLenient(chars, 0, chars.length, randomBoolean()), is(true));
}
}

View File

@ -11,6 +11,7 @@ package org.elasticsearch.index;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.ESTestCase;
@ -28,7 +29,7 @@ public class IndexSettingsOverrideTests extends ESTestCase {
public void testStatelessMinRefreshIntervalOverride() {
assumeTrue(
"This test depends on system property configured in build.gradle",
Boolean.parseBoolean(
Booleans.parseBoolean(
System.getProperty(IndexSettings.RefreshIntervalValidator.STATELESS_ALLOW_INDEX_REFRESH_INTERVAL_OVERRIDE, "false")
)
);

View File

@ -34,6 +34,7 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.util.NullInfoStream;
import org.apache.lucene.util.InfoStream;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.test.ESTestCase;
@ -182,7 +183,7 @@ public class RecoverySourcePruneMergePolicyTests extends ESTestCase {
Set<String> collect = document.getFields().stream().map(IndexableField::name).collect(Collectors.toSet());
assertTrue(collect.contains("source"));
assertTrue(collect.contains("even"));
boolean isEven = Boolean.parseBoolean(document.getField("even").stringValue());
boolean isEven = Booleans.parseBoolean(document.getField("even").stringValue());
if (isEven) {
assertTrue(collect.contains(IdFieldMapper.NAME));
assertThat(collect.contains("extra_source"), equalTo(syntheticRecoverySource == false));

View File

@ -32,6 +32,7 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersions;
@ -242,8 +243,8 @@ public class CompletionFieldMapperTests extends MapperTestCase {
Map<String, Object> configMap = (Map<String, Object>) serializedMap.get("field");
assertThat(configMap.get("analyzer").toString(), is("simple"));
assertThat(configMap.get("search_analyzer").toString(), is("standard"));
assertThat(Boolean.valueOf(configMap.get("preserve_separators").toString()), is(false));
assertThat(Boolean.valueOf(configMap.get("preserve_position_increments").toString()), is(true));
assertThat(Booleans.parseBoolean(configMap.get("preserve_separators").toString()), is(false));
assertThat(Booleans.parseBoolean(configMap.get("preserve_position_increments").toString()), is(true));
assertThat(Integer.valueOf(configMap.get("max_input_length").toString()), is(14));
}

View File

@ -14,6 +14,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
@ -68,7 +69,7 @@ public class XContentDataHelperTests extends ESTestCase {
public void testBoolean() throws IOException {
boolean b = randomBoolean();
assertEquals(b, Boolean.parseBoolean(encodeAndDecode(b)));
assertEquals(b, Booleans.parseBoolean(encodeAndDecode(b)));
}
public void testString() throws IOException {

View File

@ -9,6 +9,7 @@
package org.elasticsearch.index.mapper.blockloader;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.datageneration.FieldType;
import org.elasticsearch.index.mapper.BlockLoaderTestCase;
@ -26,7 +27,7 @@ public class BooleanFieldBlockLoaderTests extends BlockLoaderTestCase {
protected Object expected(Map<String, Object> fieldMapping, Object value, TestContext testContext) {
var nullValue = switch (fieldMapping.get("null_value")) {
case Boolean b -> b;
case String s -> Boolean.parseBoolean(s);
case String s -> Booleans.parseBoolean(s);
case null -> null;
default -> throw new IllegalStateException("Unexpected null_value format");
};

View File

@ -12,6 +12,7 @@ package org.elasticsearch.datageneration.matchers.source;
import org.apache.lucene.sandbox.document.HalfFloatPoint;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.datageneration.matchers.MatchResult;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.xcontent.XContentBuilder;
@ -389,7 +390,7 @@ interface FieldSpecificMatcher {
Object convert(Object value, Object nullValue) {
Boolean nullValueBool = null;
if (nullValue != null) {
nullValueBool = nullValue instanceof Boolean b ? b : Boolean.parseBoolean((String) nullValue);
nullValueBool = nullValue instanceof Boolean b ? b : Booleans.parseBoolean((String) nullValue);
}
if (value == null) {
@ -401,7 +402,7 @@ interface FieldSpecificMatcher {
}
if (value instanceof String s) {
try {
return Boolean.parseBoolean(s);
return Booleans.parseBoolean(s);
} catch (Exception e) {
// malformed
return value;

View File

@ -114,6 +114,7 @@ import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.FixForMultiProject;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.Nullable;
@ -2780,7 +2781,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
}
public static boolean inFipsJvm() {
return Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP));
return Booleans.parseBoolean(System.getProperty(FIPS_SYSPROP, "false"));
}
protected void restartNodesOnBrokenClusterState(ClusterState.Builder clusterStateBuilder) throws Exception {

View File

@ -2200,7 +2200,7 @@ public abstract class ESTestCase extends LuceneTestCase {
}
public static boolean inFipsJvm() {
return Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP));
return Booleans.parseBoolean(System.getProperty(FIPS_SYSPROP, "false"));
}
/*

View File

@ -14,6 +14,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.Constants;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
@ -52,7 +53,7 @@ public class ReproduceInfoPrinter extends RunListener {
* Are we in the integ test phase?
*/
static boolean inVerifyPhase() {
return Boolean.parseBoolean(System.getProperty("tests.verify.phase"));
return Booleans.parseBoolean(System.getProperty("tests.verify.phase", "false"));
}
@Override
@ -65,7 +66,7 @@ public class ReproduceInfoPrinter extends RunListener {
final String gradlew = Constants.WINDOWS ? "gradlew" : "./gradlew";
final StringBuilder b = new StringBuilder("REPRODUCE WITH: " + gradlew + " ");
String task = System.getProperty("tests.task");
boolean isBwcTest = Boolean.parseBoolean(System.getProperty("tests.bwc", "false"))
boolean isBwcTest = Booleans.parseBoolean(System.getProperty("tests.bwc", "false"))
|| System.getProperty("tests.bwc.main.version") != null
|| System.getProperty("tests.bwc.refspec.main") != null;
@ -106,7 +107,7 @@ public class ReproduceInfoPrinter extends RunListener {
}
private static boolean isRestApiCompatibilityTest() {
return Boolean.parseBoolean(System.getProperty("tests.restCompat", "false"));
return Booleans.parseBoolean(System.getProperty("tests.restCompat", "false"));
}
@SuppressForbidden(reason = "printing repro info")
@ -183,7 +184,7 @@ public class ReproduceInfoPrinter extends RunListener {
if (System.getProperty("tests.jvm.argline") != null && System.getProperty("tests.jvm.argline").isEmpty() == false) {
appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");
}
if (Boolean.parseBoolean(System.getProperty("build.snapshot", "true")) == false) {
if (Booleans.parseBoolean(System.getProperty("build.snapshot", "true")) == false) {
appendOpt("license.key", "x-pack/license-tools/src/test/resources/public.key");
}
appendOpt("tests.locale", Locale.getDefault().toLanguageTag());

View File

@ -61,6 +61,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CharArrays;
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.core.CheckedRunnable;
@ -369,7 +370,7 @@ public abstract class ESRestTestCase extends ESTestCase {
// The active project-id is slightly longer, and has a fixed prefix so that it's easier to pick in error messages etc.
activeProject = "active00" + randomAlphaOfLength(8).toLowerCase(Locale.ROOT);
extraProjects = randomSet(1, 3, () -> randomAlphaOfLength(12).toLowerCase(Locale.ROOT));
multiProjectEnabled = Boolean.parseBoolean(System.getProperty("tests.multi_project.enabled"));
multiProjectEnabled = Booleans.parseBoolean(System.getProperty("tests.multi_project.enabled", "false"));
}
@Before

View File

@ -10,6 +10,7 @@
package org.elasticsearch.test.rest;
import org.elasticsearch.Version;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.Strings;
import org.elasticsearch.core.SuppressForbidden;
@ -109,7 +110,7 @@ class ESRestTestFeatureService implements TestFeatureService {
}
private static boolean isRestApiCompatibilityTest() {
return Boolean.parseBoolean(System.getProperty("tests.restCompat", "false"));
return Booleans.parseBoolean(System.getProperty("tests.restCompat", "false"));
}
public static boolean hasFeatureMetadata() {

View File

@ -11,6 +11,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.Booleans;
import java.io.IOException;
import java.util.Locale;
@ -61,7 +62,7 @@ public enum PredictionFieldType implements Writeable {
// do nothing, allow fall through to final fromDouble
}
} else if (isBoolQuickCheck(stringRep)) { // if we start with t/f case insensitive, it indicates boolean string
return Boolean.parseBoolean(stringRep);
return Booleans.parseBooleanLenient(stringRep, false);
}
return fromDouble(value);
case NUMBER:

View File

@ -8,6 +8,7 @@
package org.elasticsearch.xpack.core.security.action.apikey;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
@ -83,7 +84,7 @@ public class GetApiKeyRequestTests extends ESTestCase {
.userName(inputs[caseNo][1])
.apiKeyId(inputs[caseNo][2])
.apiKeyName(inputs[caseNo][3])
.ownedByAuthenticatedUser(Boolean.parseBoolean(inputs[caseNo][4]))
.ownedByAuthenticatedUser(Booleans.parseBoolean(inputs[caseNo][4]))
.withProfileUid(randomBoolean())
.build();
ActionRequestValidationException ve = request.validate();

View File

@ -15,6 +15,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import java.io.ByteArrayInputStream;
@ -105,7 +106,7 @@ public class InvalidateApiKeyRequestTests extends ESTestCase {
user = a[1];
apiKeyId = a[2];
apiKeyName = a[3];
ownedByAuthenticatedUser = Boolean.parseBoolean(a[4]);
ownedByAuthenticatedUser = Booleans.parseBoolean(a[4]);
}
@Override

View File

@ -24,6 +24,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
@ -133,7 +134,7 @@ public class EsEQLCorrectnessIT extends ESRestTestCase {
// To enable test of subqueries (filtering) results: -Dtests.eql_correctness_debug=true
@SuppressWarnings("unchecked")
public void test() throws Exception {
boolean debugMode = Boolean.parseBoolean(System.getProperty("tests.eql_correctness_debug", "false"));
boolean debugMode = Booleans.parseBoolean(System.getProperty("tests.eql_correctness_debug", "false"));
int queryNo = spec.queryNo();
if (debugMode) {

View File

@ -23,7 +23,7 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
/**
* Consumes the "Nullable" and "Inject" annotations and does nothing with them
* Consumes the "Nullable", "Inject" and "SuppressForbidden" annotations and does nothing with them
* to prevent warnings when running annotation processors.
*/
public class ConsumeProcessor implements Processor {
@ -38,6 +38,7 @@ public class ConsumeProcessor implements Processor {
"org.elasticsearch.xpack.esql.SupportsObservabilityTier",
"org.elasticsearch.core.Nullable",
"org.elasticsearch.injection.guice.Inject",
"org.elasticsearch.core.SuppressForbidden",
"org.elasticsearch.xpack.esql.expression.function.FunctionInfo",
"org.elasticsearch.xpack.esql.expression.function.Param",
"org.elasticsearch.xpack.esql.expression.function.MapParam",

View File

@ -67,6 +67,7 @@ import org.elasticsearch.compute.test.SequenceLongBlockSourceOperator;
import org.elasticsearch.compute.test.TestBlockFactory;
import org.elasticsearch.compute.test.TestDriverFactory;
import org.elasticsearch.compute.test.TestResultPageSinkOperator;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.core.TimeValue;
@ -1915,7 +1916,7 @@ public class ValueSourceReaderTypeConversionTests extends AnyOperatorTestCase {
@Override
Boolean evalValue(BytesRefBlock container, int index, BytesRef scratchPad) {
return Boolean.parseBoolean(container.getBytesRef(index, scratchPad).utf8ToString());
return Booleans.parseBoolean(container.getBytesRef(index, scratchPad).utf8ToString());
}
}

View File

@ -17,6 +17,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.logging.ESLogMessage;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xpack.esql.MockAppender;
import org.elasticsearch.xpack.esql.VerificationException;
@ -195,7 +196,7 @@ public class EsqlQueryLogIT extends AbstractEsqlIntegTestCase {
assertThat(msg.get(ELASTICSEARCH_QUERYLOG_QUERY), is(query));
assertThat(appender.getLastEventAndReset().getLevel(), equalTo(logLevel.getKey()));
boolean success = Boolean.valueOf(msg.get(ELASTICSEARCH_QUERYLOG_SUCCESS));
boolean success = Booleans.parseBoolean(msg.get(ELASTICSEARCH_QUERYLOG_SUCCESS));
assertThat(success, is(expectedException == null));
if (expectedErrorMsg == null) {
assertThat(msg.get(ELASTICSEARCH_QUERYLOG_ERROR_MESSAGE), is(nullValue()));

View File

@ -21,6 +21,7 @@ import org.elasticsearch.compute.data.AggregateMetricDoubleBlockBuilder;
import org.elasticsearch.compute.data.AggregateMetricDoubleBlockBuilder.Metric;
import org.elasticsearch.compute.data.DoubleBlock;
import org.elasticsearch.compute.data.IntBlock;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
@ -600,7 +601,7 @@ public class EsqlDataTypeConverter {
}
public static boolean stringToBoolean(String field) {
return Boolean.parseBoolean(field);
return Booleans.parseBooleanLenient(field, false);
}
public static int stringToInt(String field) {

View File

@ -14,6 +14,7 @@ import org.elasticsearch.client.WarningFailureException;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Template;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.engine.EngineConfig;
import org.elasticsearch.test.rest.ESRestTestCase;
@ -85,7 +86,7 @@ public class TimeSeriesDataStreamsIT extends ESRestTestCase {
final var backingIndices = getDataStreamBackingIndexNames(dataStream);
assertEquals(2, backingIndices.size());
try {
assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden")));
assertTrue(Booleans.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden")));
assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst()));
} catch (ResponseException e) {
// These API calls may hit different nodes and they might see slightly different versions of the cluster state,

View File

@ -37,6 +37,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.FormatNames;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.datastreams.DataStreamsPlugin;
import org.elasticsearch.index.Index;
@ -72,7 +73,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static java.lang.Boolean.parseBoolean;
import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.DEFAULT_TIMESTAMP_FIELD;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
@ -376,9 +376,9 @@ public class ReindexDatastreamIndexTransportActionIT extends ESIntegTestCase {
).getDestIndex();
var settingsResponse = safeGet(indicesAdmin().getSettings(new GetSettingsRequest(TEST_REQUEST_TIMEOUT).indices(destIndex)));
assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY)));
assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE)));
assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE)));
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY), false));
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE), false));
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE), false));
cleanupMetadataBlocks(destIndex);
}

View File

@ -9,6 +9,7 @@ package org.elasticsearch.xpack.repositories.metering.s3;
import fixture.s3.S3HttpFixture;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.xpack.repositories.metering.AbstractRepositoriesMeteringAPIRestTestCase;
@ -21,7 +22,7 @@ import java.util.Map;
public class S3RepositoriesMeteringIT extends AbstractRepositoriesMeteringAPIRestTestCase {
static final boolean USE_FIXTURE = Boolean.parseBoolean(System.getProperty("tests.use.fixture", "true"));
static final boolean USE_FIXTURE = Booleans.parseBoolean(System.getProperty("tests.use.fixture", "true"));
public static final S3HttpFixture s3Fixture = new S3HttpFixture(USE_FIXTURE);

View File

@ -9,6 +9,7 @@ package org.elasticsearch.xpack.searchablesnapshots.s3;
import fixture.s3.S3HttpFixture;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.xpack.searchablesnapshots.AbstractSearchableSnapshotsRestTestCase;
@ -20,7 +21,7 @@ import static org.hamcrest.Matchers.blankOrNullString;
import static org.hamcrest.Matchers.not;
public class S3SearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTestCase {
static final boolean USE_FIXTURE = Boolean.parseBoolean(System.getProperty("tests.use.fixture", "true"));
static final boolean USE_FIXTURE = Booleans.parseBoolean(System.getProperty("tests.use.fixture", "true"));
public static final S3HttpFixture s3Fixture = new S3HttpFixture(USE_FIXTURE);

View File

@ -18,6 +18,7 @@ import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Strings;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchResponseUtils;
@ -647,7 +648,7 @@ public class RemoteClusterSecurityRestIT extends AbstractRemoteClusterSecurityTe
// remote cluster is not reported in transport profiles
assertThat(ObjectPath.eval("transport.profiles", node), anEmptyMap());
if (Boolean.parseBoolean(ObjectPath.eval("settings.remote_cluster_server.enabled", node))) {
if (Booleans.parseBoolean(ObjectPath.eval("settings.remote_cluster_server.enabled", node))) {
numberOfRemoteClusterServerNodes += 1;
final List<String> boundAddresses = ObjectPath.eval("remote_cluster_server.bound_address", node);
assertThat(boundAddresses, notNullValue());

View File

@ -453,8 +453,8 @@ class SetupPasswordTool extends MultiCommand {
Map<String, Object> featureInfo = (Map<String, Object>) features.get("security");
if (featureInfo != null) {
xPackSecurityFeatureConfig = new XPackSecurityFeatureConfig(
Boolean.parseBoolean(featureInfo.get("available").toString()),
Boolean.parseBoolean(featureInfo.get("enabled").toString())
Booleans.parseBoolean(featureInfo.get("available").toString()),
Booleans.parseBoolean(featureInfo.get("enabled").toString())
);
return xPackSecurityFeatureConfig;
}

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.MockSecureSettings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Strings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
@ -233,7 +234,7 @@ public class JwtRealmSettingsTests extends JwtTestCase {
final Settings settings = Settings.builder().put(settingKey, acceptedValue).build();
final RealmConfig realmConfig = buildRealmConfig(JwtRealmSettings.TYPE, realmName, settings, 0);
final Boolean actualValue = realmConfig.getSetting(setting);
assertThat(actualValue, equalTo(Boolean.valueOf(acceptedValue)));
assertThat(actualValue, equalTo(Booleans.parseBoolean(acceptedValue)));
}
}

View File

@ -9,6 +9,7 @@ package org.elasticsearch.upgrades;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xpack.test.SecuritySettingsSourceField;
@ -37,7 +38,7 @@ public abstract class AbstractUpgradeTestCase extends ESRestTestCase {
}
protected static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.suite"));
protected static final boolean FIRST_MIXED_ROUND = Boolean.parseBoolean(System.getProperty("tests.first_round", "false"));
protected static final boolean FIRST_MIXED_ROUND = Booleans.parseBoolean(System.getProperty("tests.first_round", "false"));
@Override
protected Settings restClientSettings() {

View File

@ -29,6 +29,7 @@ import org.elasticsearch.common.scheduler.SchedulerEngine;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Strings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
@ -206,7 +207,7 @@ public class SnapshotLifecycleTaskTests extends ESTestCase {
assertThat(Arrays.asList(req.indices()), equalTo(policy.getConfig().get("indices")));
}
boolean globalState = policy.getConfig().get("include_global_state") == null
|| Boolean.parseBoolean((String) policy.getConfig().get("include_global_state"));
|| Booleans.parseBoolean((String) policy.getConfig().get("include_global_state"));
assertThat(req.includeGlobalState(), equalTo(globalState));
try {
@ -285,7 +286,7 @@ public class SnapshotLifecycleTaskTests extends ESTestCase {
assertThat(Arrays.asList(req.indices()), equalTo(policy.getConfig().get("indices")));
}
boolean globalState = policy.getConfig().get("include_global_state") == null
|| Boolean.parseBoolean((String) policy.getConfig().get("include_global_state"));
|| Booleans.parseBoolean((String) policy.getConfig().get("include_global_state"));
assertThat(req.includeGlobalState(), equalTo(globalState));
long startTime = randomNonNegativeLong();

View File

@ -10,6 +10,7 @@ package org.elasticsearch.xpack.snapshotbasedrecoveries.recovery;
import fixture.s3.S3HttpFixture;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.junit.ClassRule;
@ -21,7 +22,7 @@ import static org.hamcrest.Matchers.not;
public class S3SnapshotBasedRecoveryIT extends AbstractSnapshotBasedRecoveryRestTestCase {
static final boolean USE_FIXTURE = Boolean.parseBoolean(System.getProperty("tests.use.fixture", "true"));
static final boolean USE_FIXTURE = Booleans.parseBoolean(System.getProperty("tests.use.fixture", "true"));
public static final S3HttpFixture s3Fixture = new S3HttpFixture(USE_FIXTURE);

View File

@ -15,6 +15,7 @@ import com.sun.net.httpserver.HttpHandler;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.junit.ClassRule;
@ -30,7 +31,7 @@ import static org.hamcrest.Matchers.not;
public class S3RepositoryAnalysisRestIT extends AbstractRepositoryAnalysisRestTestCase {
static final boolean USE_FIXTURE = Boolean.parseBoolean(System.getProperty("tests.use.fixture", "true"));
static final boolean USE_FIXTURE = Booleans.parseBoolean(System.getProperty("tests.use.fixture", "true"));
private static final Supplier<String> regionSupplier = new DynamicRegionSupplier();
public static final S3HttpFixture s3Fixture = new S3HttpFixture(

View File

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.sql.jdbc;
import org.elasticsearch.xpack.sql.proto.StringUtils;
import org.elasticsearch.xpack.sql.proto.core.Booleans;
import java.math.BigDecimal;
import java.math.BigInteger;
@ -325,7 +326,7 @@ final class TypeConverter {
return Boolean.valueOf(((Number) val).doubleValue() != 0);
case KEYWORD:
case TEXT:
return Boolean.valueOf((String) val);
return Booleans.parseBooleanLenient((String) val, false);
default:
return failConversion(val, columnType, typeString, Boolean.class);
}

View File

@ -18,6 +18,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xcontent.ObjectParser;
import org.elasticsearch.xcontent.ParseField;
@ -251,7 +252,7 @@ public final class ReportingAttachmentParser implements EmailAttachmentParser<Re
WARNINGS.forEach((warningKey, defaultWarning) -> {
String[] text = response.header(warningKey);
if (text != null && text.length > 0) {
if (Boolean.valueOf(text[0])) {
if (parseBoolean(text[0])) {
String warning = String.format(Locale.ROOT, defaultWarning, attachment.id());
String customWarning = customWarnings.get(warningKey);
if (Strings.isNullOrEmpty(customWarning) == false) {
@ -296,6 +297,13 @@ public final class ReportingAttachmentParser implements EmailAttachmentParser<Re
);
}
@SuppressForbidden(
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
)
private static boolean parseBoolean(String s) {
return Boolean.valueOf(s);
}
private static void sleep(long sleepMillis, WatchExecutionContext context, ReportingAttachment attachment) {
try {
Thread.sleep(sleepMillis);

View File

@ -8,6 +8,7 @@ package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.test.rest.FakeRestRequest.Builder;
@ -38,9 +39,9 @@ public class RestExecuteWatchActionTests extends ESTestCase {
);
assertThat(request.getId(), is(randomId));
assertThat(request.isRecordExecution(), is(Boolean.parseBoolean(recordExecution)));
assertThat(request.isIgnoreCondition(), is(Boolean.parseBoolean(ignoreCondition)));
assertThat(request.isDebug(), is(Boolean.parseBoolean(debugCondition)));
assertThat(request.isRecordExecution(), is(Booleans.parseBoolean(recordExecution, false)));
assertThat(request.isIgnoreCondition(), is(Booleans.parseBoolean(ignoreCondition, false)));
assertThat(request.isDebug(), is(Booleans.parseBoolean(debugCondition, false)));
}
}
}

View File

@ -17,6 +17,7 @@ import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.ESTestCase;
@ -85,7 +86,7 @@ public class SimpleKdcLdapServer {
@Override
@SuppressForbidden(reason = "set or clear system property krb5 debug in kerberos tests")
public Boolean run() throws Exception {
boolean oldDebugSetting = Boolean.parseBoolean(System.getProperty("sun.security.krb5.debug"));
boolean oldDebugSetting = Booleans.parseBoolean(System.getProperty("sun.security.krb5.debug", "false"));
System.setProperty("sun.security.krb5.debug", Boolean.TRUE.toString());
return oldDebugSetting;
}

View File

@ -19,6 +19,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
@ -141,7 +142,7 @@ public class KerberosAuthenticationIT extends ESRestTestCase {
public void testLoginByKeytab() throws IOException, PrivilegedActionException {
final String keytabPath = krb5Fixture.getKeytab().toString();
final boolean enabledDebugLogs = Boolean.parseBoolean(ENABLE_KERBEROS_DEBUG_LOGS_KEY);
final boolean enabledDebugLogs = Booleans.parseBoolean(System.getProperty(ENABLE_KERBEROS_DEBUG_LOGS_KEY), false);
final SpnegoHttpClientConfigCallbackHandler callbackHandler = new SpnegoHttpClientConfigCallbackHandler(
krb5Fixture.getPrincipal(),
keytabPath,
@ -153,7 +154,7 @@ public class KerberosAuthenticationIT extends ESRestTestCase {
public void testLoginByUsernamePassword() throws IOException, PrivilegedActionException {
final String userPrincipalName = TEST_USER_WITH_PWD_KEY;
final String password = TEST_USER_WITH_PWD_PASSWD_KEY;
final boolean enabledDebugLogs = Boolean.parseBoolean(System.getProperty(ENABLE_KERBEROS_DEBUG_LOGS_KEY));
final boolean enabledDebugLogs = Booleans.parseBoolean(System.getProperty(ENABLE_KERBEROS_DEBUG_LOGS_KEY), false);
final SpnegoHttpClientConfigCallbackHandler callbackHandler = new SpnegoHttpClientConfigCallbackHandler(
userPrincipalName,
new SecureString(password.toCharArray()),
@ -165,7 +166,7 @@ public class KerberosAuthenticationIT extends ESRestTestCase {
public void testGetOauth2TokenInExchangeForKerberosTickets() throws PrivilegedActionException, GSSException, IOException {
final String userPrincipalName = TEST_USER_WITH_PWD_KEY;
final String password = TEST_USER_WITH_PWD_PASSWD_KEY;
final boolean enabledDebugLogs = Boolean.parseBoolean(System.getProperty(ENABLE_KERBEROS_DEBUG_LOGS_KEY));
final boolean enabledDebugLogs = Booleans.parseBoolean(System.getProperty(ENABLE_KERBEROS_DEBUG_LOGS_KEY), false);
final SpnegoHttpClientConfigCallbackHandler callbackHandler = new SpnegoHttpClientConfigCallbackHandler(
userPrincipalName,
new SecureString(password.toCharArray()),

View File

@ -34,7 +34,7 @@ public abstract class AbstractUpgradeTestCase extends ESRestTestCase {
);
protected static final String UPGRADE_FROM_VERSION = System.getProperty("tests.upgrade_from_version");
protected static final boolean FIRST_MIXED_ROUND = Boolean.parseBoolean(System.getProperty("tests.first_round", "false"));
protected static final boolean FIRST_MIXED_ROUND = Booleans.parseBoolean(System.getProperty("tests.first_round", "false"));
protected static final boolean SKIP_ML_TESTS = Booleans.parseBoolean(System.getProperty("tests.ml.skip", "false"));
protected static boolean isOriginalCluster(String clusterVersion) {

View File

@ -11,6 +11,7 @@ import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.Strings;
import org.elasticsearch.logging.LogManager;
@ -31,7 +32,7 @@ import static org.hamcrest.Matchers.hasSize;
public class MlAssignmentPlannerUpgradeIT extends AbstractUpgradeTestCase {
private static final boolean IS_SINGLE_PROCESSOR_TEST = Boolean.parseBoolean(
private static final boolean IS_SINGLE_PROCESSOR_TEST = Booleans.parseBoolean(
System.getProperty("tests.configure_test_clusters_with_one_processor", "false")
);