Skip to content

Commit 61bc66b

Browse files
committed
Resolve comments
1 parent 457f5cc commit 61bc66b

File tree

10 files changed

+31
-37
lines changed

10 files changed

+31
-37
lines changed

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ public Set<ScriptContext<?>> getSupportedContexts() {
9797
return Set.of(TemplateScript.CONTEXT, TemplateScript.INGEST_CONTEXT);
9898
}
9999

100-
@SuppressForbidden(
101-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
102-
)
103100
private static CustomMustacheFactory createMustacheFactory(Map<String, String> options) {
104101
CustomMustacheFactory.Builder builder = CustomMustacheFactory.builder();
105102
if (options == null || options.isEmpty()) {
@@ -111,12 +108,19 @@ private static CustomMustacheFactory createMustacheFactory(Map<String, String> o
111108
}
112109

113110
if (options.containsKey(DETECT_MISSING_PARAMS_OPTION)) {
114-
builder.detectMissingParams(Boolean.valueOf(options.get(DETECT_MISSING_PARAMS_OPTION)));
111+
builder.detectMissingParams(getDetectMissingParamsOption(options));
115112
}
116113

117114
return builder.build();
118115
}
119116

117+
@SuppressForbidden(
118+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
119+
)
120+
private static boolean getDetectMissingParamsOption(Map<String, String> options) {
121+
return Boolean.valueOf(options.get(DETECT_MISSING_PARAMS_OPTION));
122+
}
123+
120124
@Override
121125
public String getType() {
122126
return NAME;

modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ ScriptScope compile(Compiler compiler, Loader loader, String scriptName, String
392392
}
393393
}
394394

395-
@SuppressForbidden(
396-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
397-
)
398395
private CompilerSettings buildCompilerSettings(Map<String, String> params) {
399396
CompilerSettings compilerSettings;
400397
if (params.isEmpty()) {
@@ -418,7 +415,7 @@ private CompilerSettings buildCompilerSettings(Map<String, String> params) {
418415

419416
value = copy.remove(CompilerSettings.PICKY);
420417
if (value != null) {
421-
compilerSettings.setPicky(Boolean.parseBoolean(value));
418+
compilerSettings.setPicky(parseBoolean(value));
422419
}
423420

424421
value = copy.remove(CompilerSettings.INITIAL_CALL_SITE_DEPTH);
@@ -443,6 +440,13 @@ private CompilerSettings buildCompilerSettings(Map<String, String> params) {
443440
return compilerSettings;
444441
}
445442

443+
@SuppressForbidden(
444+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
445+
)
446+
private static boolean parseBoolean(String value) {
447+
return Boolean.parseBoolean(value);
448+
}
449+
446450
private static ScriptException convertToScriptException(String scriptSource, Throwable t) {
447451
// create a script stack: this is just the script portion
448452
List<String> scriptStack = new ArrayList<>();

server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.elasticsearch.common.util.concurrent.CountDown;
3939
import org.elasticsearch.common.util.concurrent.EsExecutors;
4040
import org.elasticsearch.core.Nullable;
41-
import org.elasticsearch.core.SuppressForbidden;
4241
import org.elasticsearch.index.Index;
4342
import org.elasticsearch.injection.guice.Inject;
4443
import org.elasticsearch.search.SearchService;
@@ -630,7 +629,7 @@ private static void enrichIndexAbstraction(
630629
if (ia.isSystem()) {
631630
attributes.add(Attribute.SYSTEM);
632631
}
633-
final boolean isFrozen = isFrozen(writeIndex);
632+
final boolean isFrozen = writeIndex.getSettings().getAsBoolean("index.frozen", false);
634633
if (isFrozen) {
635634
attributes.add(Attribute.FROZEN);
636635
}
@@ -666,13 +665,6 @@ private static void enrichIndexAbstraction(
666665
}
667666
}
668667

669-
@SuppressForbidden(
670-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
671-
)
672-
private static boolean isFrozen(IndexMetadata writeIndex) {
673-
return Boolean.parseBoolean(writeIndex.getSettings().get("index.frozen"));
674-
}
675-
676668
private static Stream<Index> getAliasIndexStream(
677669
ResolvedExpression resolvedExpression,
678670
IndexAbstraction ia,

server/src/main/java/org/elasticsearch/common/network/NetworkUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private NetworkUtils() {}
5050
@SuppressForbidden(
5151
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
5252
)
53-
static boolean preferIPv6Addresses() {
53+
private static boolean preferIPv6Addresses() {
5454
return Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false"));
5555
}
5656

server/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.elasticsearch.core.CheckedFunction;
3939
import org.elasticsearch.core.IOUtils;
4040
import org.elasticsearch.core.Nullable;
41-
import org.elasticsearch.core.SuppressForbidden;
4241
import org.elasticsearch.core.TimeValue;
4342
import org.elasticsearch.env.NodeEnvironment;
4443
import org.elasticsearch.env.ShardLock;
@@ -247,7 +246,7 @@ public IndexService(
247246
mapperMetrics
248247
);
249248
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
250-
boolean sourceOnly = isSourceOnly(indexSettings);
249+
boolean sourceOnly = indexSettings.getSettings().getAsBoolean("index.source_only", false);
251250
if (indexSettings.getIndexSortConfig().hasIndexSort() && sourceOnly == false) {
252251
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
253252
// The sort order is validated right after the merge of the mapping later in the process.
@@ -310,13 +309,6 @@ static boolean needsMapperService(IndexSettings indexSettings, IndexCreationCont
310309
&& indexCreationContext == IndexCreationContext.CREATE_INDEX); // metadata verification needs a mapper service
311310
}
312311

313-
@SuppressForbidden(
314-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
315-
)
316-
static boolean isSourceOnly(IndexSettings indexSettings) {
317-
return Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only"));
318-
}
319-
320312
public enum IndexCreationContext {
321313
CREATE_INDEX,
322314
METADATA_VERIFICATION,

server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class ES819TSDBDocValuesFormat extends org.apache.lucene.codecs.DocValues
100100
@SuppressForbidden(
101101
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
102102
)
103-
static boolean getOptimizedMergeEnabledDefault() {
103+
private static boolean getOptimizedMergeEnabledDefault() {
104104
return Boolean.parseBoolean(System.getProperty(OPTIMIZED_MERGE_ENABLED_NAME, Boolean.TRUE.toString()));
105105
}
106106

server/src/main/java/org/elasticsearch/search/SearchService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static <T> ActionListener<T> wrapListenerForErrorHandling(
632632
@SuppressForbidden(
633633
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
634634
)
635-
static boolean getErrorTraceHeader(ThreadPool threadPool) {
635+
private static boolean getErrorTraceHeader(ThreadPool threadPool) {
636636
return Boolean.parseBoolean(threadPool.getThreadContext().getHeaderOrDefault("error_trace", "false"));
637637
}
638638

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/PredictionFieldType.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public String toString() {
4646
return name().toLowerCase(Locale.ROOT);
4747
}
4848

49-
@SuppressForbidden(reason = "accept lenient boolean field values")
5049
public Object transformPredictedValue(Double value, String stringRep) {
5150
if (value == null) {
5251
return null;
@@ -63,7 +62,7 @@ public Object transformPredictedValue(Double value, String stringRep) {
6362
// do nothing, allow fall through to final fromDouble
6463
}
6564
} else if (isBoolQuickCheck(stringRep)) { // if we start with t/f case insensitive, it indicates boolean string
66-
return Boolean.parseBoolean(stringRep);
65+
return parseBoolean(stringRep);
6766
}
6867
return fromDouble(value);
6968
case NUMBER:
@@ -82,6 +81,11 @@ public Object transformPredictedValue(Double value, String stringRep) {
8281
}
8382
}
8483

84+
@SuppressForbidden(reason = "accept lenient boolean field values")
85+
private static boolean parseBoolean(String value) {
86+
return Boolean.parseBoolean(value);
87+
}
88+
8589
private static boolean fromDouble(double value) {
8690
if ((areClose(value, 1.0D) || areClose(value, 0.0D)) == false) {
8791
throw new IllegalArgumentException(

x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/xpack/migrate/action/ReindexDatastreamIndexTransportActionIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ public void testReadOnlyBlocksNotAddedBack() {
376376
).getDestIndex();
377377

378378
var settingsResponse = safeGet(indicesAdmin().getSettings(new GetSettingsRequest(TEST_REQUEST_TIMEOUT).indices(destIndex)));
379-
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY)));
380-
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE)));
381-
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE)));
379+
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY), false));
380+
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE), false));
381+
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE), false));
382382

383383
cleanupMetadataBlocks(destIndex);
384384
}

x-pack/plugin/sql/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/TypeConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ private static <T> T failConversion(Object value, EsType columnType, String type
311311
throw e != null ? new SQLException(message, e) : new SQLException(message);
312312
}
313313

314-
@SuppressForbidden(
315-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
316-
)
314+
@SuppressForbidden(reason = "allow lenient conversion to boolean")
317315
private static Boolean asBoolean(Object val, EsType columnType, String typeString) throws SQLException {
318316
switch (columnType) {
319317
case BOOLEAN:

0 commit comments

Comments
 (0)