Skip to content
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

Reduce duplicate and dead entitlements code #121409

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Conversation

prdoyle
Copy link
Contributor

@prdoyle prdoyle commented Jan 31, 2025

This does three things:

  1. Remove the duplicate canWrite methods taking File and Path. This served as a good demonstration of how Path and File handling could be specialized in the future, but as long as they are identical, the duplication causes more harm than good. Let's not maintain two of these until the need arises.
  2. Remove the second neverEntitled method taking a String; always use the Supplier<String>. The original motivation was to avoid allocating a lambda object on each call, but since that's a highly optimized operation in the JVM, it's unlikely to make a difference in practice, and this smacks of premature optimization. We're pretty liberal about lambdas elsewhere, so let's not sweat it here until we have some evidence that it matters.
  3. Delete some unused methods and variables.

Note: this likely won't backport cleanly to 8.18 or 9.0 until #121250 is backported.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.
The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.
@prdoyle prdoyle added >non-issue :Core/Infra/Core Core issues without another label auto-backport Automatically create backport pull requests when merged test-entitlements Trigger CI checks using security manager replacement v8.18.1 v8.19.0 v9.0.1 v9.1.0 labels Jan 31, 2025
@prdoyle prdoyle self-assigned this Jan 31, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Jan 31, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@prdoyle prdoyle enabled auto-merge (squash) January 31, 2025 15:16
@prdoyle prdoyle merged commit f205061 into elastic:main Jan 31, 2025
21 of 22 checks passed
prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.18
8.x
9.0

elasticsearchmachine pushed a commit that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
prdoyle added a commit that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
@prdoyle prdoyle deleted the cleanup2 branch January 31, 2025 18:45
elasticsearchmachine pushed a commit that referenced this pull request Jan 31, 2025
* Refactor: remove duplicate canWrite methods.

This serves as a good example of how Path and File handling could be
specialized in the future, but as long as they are identical, the duplication
causes more harm than good.

* Refactor: just one neverEntitled.

The original motivation was to avoid allocating a lambda object on each call,
but since that's a highly optimized operation in the JVM, it's unlikely to make
a difference in practice, and this smacks of premature optimization.

We're pretty liberal about lambdas elsewhere, so let's not sweat it here until
we have some evidence that it matters.

* Remove dead code
@prdoyle prdoyle mentioned this pull request Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team test-entitlements Trigger CI checks using security manager replacement v8.18.1 v8.19.0 v9.0.1 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants