Skip to content

Commit 5196d60

Browse files
committed
Remove suppression and replace with Booleans.parseBoolean
1 parent 288c0b5 commit 5196d60

File tree

10 files changed

+68
-40
lines changed

10 files changed

+68
-40
lines changed

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

Lines changed: 2 additions & 4 deletions
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;
@@ -189,12 +190,9 @@ private static void parseCsv(Path csvPath, MethodDescriptorConsumer methodConsum
189190
}
190191
}
191192

192-
@SuppressForbidden(
193-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
194-
)
195193
public static void main(String[] args) throws IOException {
196194
var csvFilePath = Path.of(args[0]);
197-
boolean bubbleUpFromPublic = args.length >= 2 && Boolean.parseBoolean(args[1]);
195+
boolean bubbleUpFromPublic = args.length >= 2 && Booleans.parseBoolean(args[1]);
198196
parseCsv(csvFilePath, (method, module, access) -> identifyTopLevelEntryPoints(method, module, access, bubbleUpFromPublic));
199197
}
200198
}

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/NettyAllocator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
import java.util.Arrays;
3333
import java.util.concurrent.atomic.AtomicBoolean;
3434

35-
@SuppressForbidden(
36-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
37-
)
3835
public class NettyAllocator {
3936

4037
private static final Logger logger = LogManager.getLogger(NettyAllocator.class);
@@ -59,7 +56,7 @@ public class NettyAllocator {
5956
+ ", factors={es.unsafe.use_netty_default_allocator=true}]";
6057
} else {
6158
final long heapSizeInBytes = JvmInfo.jvmInfo().getMem().getHeapMax().getBytes();
62-
final boolean g1gcEnabled = Boolean.parseBoolean(JvmInfo.jvmInfo().useG1GC());
59+
final boolean g1gcEnabled = useG1GC();
6360
final long g1gcRegionSizeInBytes = JvmInfo.jvmInfo().getG1RegionSize();
6461
final boolean g1gcRegionSizeIsKnown = g1gcRegionSizeInBytes != -1;
6562
ByteSizeValue heapSize = ByteSizeValue.ofBytes(heapSizeInBytes);
@@ -173,6 +170,13 @@ public int pageSize() {
173170
};
174171
}
175172

173+
@SuppressForbidden(
174+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
175+
)
176+
private static boolean useG1GC() {
177+
return Boolean.parseBoolean(JvmInfo.jvmInfo().useG1GC());
178+
}
179+
176180
public static void logAllocatorDescriptionIfNeeded() {
177181
if (descriptionLogged.compareAndSet(false, true)) {
178182
logger.info("creating NettyAllocator with the following configs: " + NettyAllocator.getAllocatorDescription());

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,6 @@ private static void mergeResults(
608608
}
609609
}
610610

611-
@SuppressForbidden(
612-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
613-
)
614611
private static void enrichIndexAbstraction(
615612
ProjectState projectState,
616613
ResolvedExpression resolvedExpression,
@@ -633,7 +630,7 @@ private static void enrichIndexAbstraction(
633630
if (ia.isSystem()) {
634631
attributes.add(Attribute.SYSTEM);
635632
}
636-
final boolean isFrozen = Boolean.parseBoolean(writeIndex.getSettings().get("index.frozen"));
633+
final boolean isFrozen = isFrozen(writeIndex);
637634
if (isFrozen) {
638635
attributes.add(Attribute.FROZEN);
639636
}
@@ -669,6 +666,13 @@ private static void enrichIndexAbstraction(
669666
}
670667
}
671668

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+
672676
private static Stream<Index> getAliasIndexStream(
673677
ResolvedExpression resolvedExpression,
674678
IndexAbstraction ia,

server/src/main/java/org/elasticsearch/cluster/metadata/LifecycleExecutionState.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ public static Builder builder(LifecycleExecutionState state) {
9292
.setStepTime(state.stepTime);
9393
}
9494

95-
@SuppressForbidden(
96-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
97-
)
9895
public static LifecycleExecutionState fromCustomMetadata(Map<String, String> customData) {
9996
Builder builder = builder();
10097
String phase = customData.get(PHASE);
@@ -115,7 +112,7 @@ public static LifecycleExecutionState fromCustomMetadata(Map<String, String> cus
115112
}
116113
String isAutoRetryableError = customData.get(IS_AUTO_RETRYABLE_ERROR);
117114
if (isAutoRetryableError != null) {
118-
builder.setIsAutoRetryableError(Boolean.parseBoolean(isAutoRetryableError));
115+
builder.setIsAutoRetryableError(parseIsAutoRetryableError(isAutoRetryableError));
119116
}
120117
String failedStepRetryCount = customData.get(FAILED_STEP_RETRY_COUNT);
121118
if (failedStepRetryCount != null) {
@@ -208,6 +205,13 @@ public static LifecycleExecutionState fromCustomMetadata(Map<String, String> cus
208205
return builder.build();
209206
}
210207

208+
@SuppressForbidden(
209+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
210+
)
211+
private static boolean parseIsAutoRetryableError(String isAutoRetryableError) {
212+
return Boolean.parseBoolean(isAutoRetryableError);
213+
}
214+
211215
/**
212216
* Converts this object to an immutable map representation for use with
213217
* {@link IndexMetadata.Builder#putCustom(String, Map)}.

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
* Utilities for network interfaces / addresses binding and publishing.
3434
* Its only intended for that purpose, not general purpose usage!!!!
3535
*/
36-
@SuppressForbidden(
37-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
38-
)
3936
public abstract class NetworkUtils {
4037

4138
/** no instantiation */
@@ -48,7 +45,14 @@ private NetworkUtils() {}
4845
* @deprecated transition mechanism only
4946
*/
5047
@Deprecated
51-
static final boolean PREFER_V6 = Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false"));
48+
static final boolean PREFER_V6 = preferIPv6Addresses();
49+
50+
@SuppressForbidden(
51+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
52+
)
53+
static boolean preferIPv6Addresses() {
54+
return Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false"));
55+
}
5256

5357
/**
5458
* True if we can bind to a v6 address. Its silly, but for *binding* we have a need to know

server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
7070
import org.elasticsearch.common.xcontent.XContentHelper;
7171
import org.elasticsearch.core.Assertions;
72+
import org.elasticsearch.core.Booleans;
7273
import org.elasticsearch.core.CheckedFunction;
7374
import org.elasticsearch.core.FixForMultiProject;
7475
import org.elasticsearch.core.IOUtils;
@@ -677,9 +678,6 @@ public OnDiskState loadOnDiskState(Path dataPath, DirectoryReader reader) throws
677678
);
678679
}
679680

680-
@SuppressForbidden(
681-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
682-
)
683681
public OnDiskStateMetadata loadOnDiskStateMetadataFromUserData(Map<String, String> userData) {
684682
assert userData.get(CURRENT_TERM_KEY) != null;
685683
assert userData.get(LAST_ACCEPTED_VERSION_KEY) != null;
@@ -693,7 +691,7 @@ public OnDiskStateMetadata loadOnDiskStateMetadataFromUserData(Map<String, Strin
693691
Long.parseLong(userData.get(LAST_ACCEPTED_VERSION_KEY)),
694692
userData.get(NODE_ID_KEY),
695693
userData.get(CLUSTER_UUID_KEY),
696-
userData.get(CLUSTER_UUID_COMMITTED_KEY) != null ? Boolean.parseBoolean(userData.get(CLUSTER_UUID_COMMITTED_KEY)) : null
694+
userData.get(CLUSTER_UUID_COMMITTED_KEY) != null ? Booleans.parseBoolean(userData.get(CLUSTER_UUID_COMMITTED_KEY)) : null
697695
);
698696
}
699697

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
177177
private final MergeMetrics mergeMetrics;
178178

179179
@SuppressWarnings("this-escape")
180-
@SuppressForbidden(
181-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
182-
)
183180
public IndexService(
184181
IndexSettings indexSettings,
185182
IndexCreationContext indexCreationContext,
@@ -250,7 +247,7 @@ public IndexService(
250247
mapperMetrics
251248
);
252249
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
253-
boolean sourceOnly = Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only"));
250+
boolean sourceOnly = isSourceOnly(indexSettings);
254251
if (indexSettings.getIndexSortConfig().hasIndexSort() && sourceOnly == false) {
255252
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
256253
// The sort order is validated right after the merge of the mapping later in the process.
@@ -313,6 +310,13 @@ static boolean needsMapperService(IndexSettings indexSettings, IndexCreationCont
313310
&& indexCreationContext == IndexCreationContext.CREATE_INDEX); // metadata verification needs a mapper service
314311
}
315312

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+
316320
public enum IndexCreationContext {
317321
CREATE_INDEX,
318322
METADATA_VERIFICATION,

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
* cpu resources.</li>
3030
* </ul>
3131
*/
32-
@SuppressForbidden(
33-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
34-
)
3532
public class ES819TSDBDocValuesFormat extends org.apache.lucene.codecs.DocValuesFormat {
3633

3734
static final int NUMERIC_BLOCK_SHIFT = 7;
@@ -97,7 +94,14 @@ public class ES819TSDBDocValuesFormat extends org.apache.lucene.codecs.DocValues
9794
static final String OPTIMIZED_MERGE_ENABLED_NAME = ES819TSDBDocValuesConsumer.class.getName() + ".enableOptimizedMerge";
9895

9996
static {
100-
OPTIMIZED_MERGE_ENABLE_DEFAULT = Boolean.parseBoolean(System.getProperty(OPTIMIZED_MERGE_ENABLED_NAME, Boolean.TRUE.toString()));
97+
OPTIMIZED_MERGE_ENABLE_DEFAULT = getOptimizedMergeEnabledDefault();
98+
}
99+
100+
@SuppressForbidden(
101+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
102+
)
103+
static boolean getOptimizedMergeEnabledDefault() {
104+
return Boolean.parseBoolean(System.getProperty(OPTIMIZED_MERGE_ENABLED_NAME, Boolean.TRUE.toString()));
101105
}
102106

103107
final int skipIndexIntervalSize;

server/src/main/java/org/elasticsearch/index/codec/vectors/es818/ES818BinaryQuantizedVectorsFormat.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@
8686
* <li>The sparse vector information, if required, mapping vector ordinal to doc ID
8787
* </ul>
8888
*/
89-
@SuppressForbidden(
90-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
91-
)
9289
public class ES818BinaryQuantizedVectorsFormat extends FlatVectorsFormat {
93-
static final boolean USE_DIRECT_IO = Boolean.parseBoolean(System.getProperty("vector.rescoring.directio", "true"));
90+
static final boolean USE_DIRECT_IO = getUseDirectIO();
9491

9592
public static final String BINARIZED_VECTOR_COMPONENT = "BVEC";
9693
public static final String NAME = "ES818BinaryQuantizedVectorsFormat";
@@ -103,6 +100,13 @@ public class ES818BinaryQuantizedVectorsFormat extends FlatVectorsFormat {
103100
static final String VECTOR_DATA_EXTENSION = "veb";
104101
static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16;
105102

103+
@SuppressForbidden(
104+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
105+
)
106+
private static boolean getUseDirectIO() {
107+
return Boolean.parseBoolean(System.getProperty("vector.rescoring.directio", "true"));
108+
}
109+
106110
private static final FlatVectorsFormat rawVectorFormat = USE_DIRECT_IO
107111
? new DirectIOLucene99FlatVectorsFormat(FlatVectorScorerUtil.getLucene99FlatVectorsScorer())
108112
: new Lucene99FlatVectorsFormat(FlatVectorScorerUtil.getLucene99FlatVectorsScorer());

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,6 @@ protected void doClose() {
590590
* @param threadPool with context where to write the new header
591591
* @return the wrapped action listener
592592
*/
593-
@SuppressForbidden(
594-
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
595-
)
596593
static <T> ActionListener<T> wrapListenerForErrorHandling(
597594
ActionListener<T> listener,
598595
TransportVersion version,
@@ -603,7 +600,7 @@ static <T> ActionListener<T> wrapListenerForErrorHandling(
603600
) {
604601
final boolean header;
605602
if (version.onOrAfter(ERROR_TRACE_IN_TRANSPORT_HEADER) && threadPool.getThreadContext() != null) {
606-
header = Boolean.parseBoolean(threadPool.getThreadContext().getHeaderOrDefault("error_trace", "false"));
603+
header = getErrorTraceHeader(threadPool);
607604
} else {
608605
header = true;
609606
}
@@ -632,6 +629,13 @@ static <T> ActionListener<T> wrapListenerForErrorHandling(
632629
});
633630
}
634631

632+
@SuppressForbidden(
633+
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993"
634+
)
635+
static boolean getErrorTraceHeader(ThreadPool threadPool) {
636+
return Boolean.parseBoolean(threadPool.getThreadContext().getHeaderOrDefault("error_trace", "false"));
637+
}
638+
635639
public void executeDfsPhase(ShardSearchRequest request, SearchShardTask task, ActionListener<SearchPhaseResult> listener) {
636640
listener = wrapListenerForErrorHandling(
637641
listener,

0 commit comments

Comments
 (0)