-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add Boolean#parseBoolean to forbidden-apis #129684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Boolean#parseBoolean to forbidden-apis #129684
Conversation
💚 CLA has been signed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your contribution @kvanerum, this is very much appreciated! I have a couple of small comments.
Could I also ask you to sign the Contributor Agreement, pls?
...llers-finder/src/main/java/org/elasticsearch/entitlement/tools/publiccallersfinder/Main.java
Outdated
Show resolved
Hide resolved
...ility/src/javaRestTest/java/org/elasticsearch/lucene/AbstractIndexCompatibilityTestCase.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java
Outdated
Show resolved
Hide resolved
modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/NettyAllocator.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/LifecycleExecutionState.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/network/NetworkUtils.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormat.java
Outdated
Show resolved
Hide resolved
Pinging @elastic/es-core-infra (Team:Core/Infra) |
@mosche Thanks for your comments — I’ve reviewed them and added |
@elasticmachine test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kvanerum thanks for addressing my comments. This is looking really good, though I have just a few more ... I also triggered tests, let's see where we're at.
@@ -96,6 +97,9 @@ public Set<ScriptContext<?>> getSupportedContexts() { | |||
return Set.of(TemplateScript.CONTEXT, TemplateScript.INGEST_CONTEXT); | |||
} | |||
|
|||
@SuppressForbidden( | |||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also extract a small helper here to minimize the scope of @SuppressForbidden
@@ -246,7 +247,7 @@ public IndexService( | |||
mapperMetrics | |||
); | |||
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService); | |||
boolean sourceOnly = Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only")); | |||
boolean sourceOnly = isSourceOnly(indexSettings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a closer look at this, this can actually be
boolean sourceOnly = isSourceOnly(indexSettings); | |
boolean sourceOnly = indexSettings.getAsBoolean("index.source_only", false); |
@SuppressForbidden( | ||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | ||
) | ||
static boolean isSourceOnly(IndexSettings indexSettings) { | ||
return Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only")); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SuppressForbidden( | |
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | |
) | |
static boolean isSourceOnly(IndexSettings indexSettings) { | |
return Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only")); | |
} |
@@ -391,6 +392,9 @@ ScriptScope compile(Compiler compiler, Loader loader, String scriptName, String | |||
} | |||
} | |||
|
|||
@SuppressForbidden( | |||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also extract a small helper here to minimize the scope of @SuppressForbidden
@@ -629,7 +630,7 @@ private static void enrichIndexAbstraction( | |||
if (ia.isSystem()) { | |||
attributes.add(Attribute.SYSTEM); | |||
} | |||
final boolean isFrozen = Boolean.parseBoolean(writeIndex.getSettings().get("index.frozen")); | |||
final boolean isFrozen = isFrozen(writeIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a closer look at this, this can actually be
final boolean isFrozen = isFrozen(writeIndex); | |
final boolean isFrozen = writeIndex.getSettings().getAsBoolean("index.frozen", false); |
@SuppressForbidden( | ||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | ||
) | ||
static boolean preferIPv6Addresses() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static boolean preferIPv6Addresses() { | |
private static boolean preferIPv6Addresses() { |
@SuppressForbidden( | ||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | ||
) | ||
static boolean getOptimizedMergeEnabledDefault() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static boolean getOptimizedMergeEnabledDefault() { | |
private static boolean getOptimizedMergeEnabledDefault() { |
@SuppressForbidden( | ||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | ||
) | ||
static boolean getErrorTraceHeader(ThreadPool threadPool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static boolean getErrorTraceHeader(ThreadPool threadPool) { | |
private static boolean getErrorTraceHeader(ThreadPool threadPool) { |
@@ -45,6 +46,7 @@ public String toString() { | |||
return name().toLowerCase(Locale.ROOT); | |||
} | |||
|
|||
@SuppressForbidden(reason = "accept lenient boolean field values") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also extract a small helper here to minimize the scope of @SuppressForbidden
@@ -310,6 +311,9 @@ private static <T> T failConversion(Object value, EsType columnType, String type | |||
throw e != null ? new SQLException(message, e) : new SQLException(message); | |||
} | |||
|
|||
@SuppressForbidden( | |||
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reason = "TODO Deprecate any lenient usage of Boolean#parseBoolean https://github.com/elastic/elasticsearch/issues/128993" | |
reason = "allow lenient conversion to boolean" |
@elasticmachine test this please |
...main/java/org/elasticsearch/index/codec/vectors/es818/ES818BinaryQuantizedVectorsFormat.java
Outdated
Show resolved
Hide resolved
@elasticmachine test this please |
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY))); | ||
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE))); | ||
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at test failures, these need to default to false
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY))); | |
assertFalse(Booleans.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE))); | |
assertFalse(Booleans.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)); |
Resolves #59190
Added
Boolean#parseBoolean
to the list of forbidden-apis.Resolved the violations against this in tests.
Marked other usages to review in #128993.