-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Adding public getter function for source field mapper excludes #20205
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?
Adding public getter function for source field mapper excludes #20205
Conversation
WalkthroughAdded a public accessor Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)
285-287: Accessor implementation is correct; consider defensive copy if immutability is desiredThe new
getExcludes()correctly exposes the configured excludes and aligns with the stated PR goal; no functional issues here. The only consideration is that returning the backingString[]allows callers to mutate the array contents and effectively change the mapper’s internal state. If you want to keepSourceFieldMappereffectively immutable, you could instead return a copy or an unmodifiable view:- public String[] getExcludes() { - return excludes; - } + public String[] getExcludes() { + return Arrays.copyOf(excludes, excludes.length); + }This is optional and depends on how much you want to protect against external mutation of mapper configuration.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: gradle-check
- GitHub Check: precommit (21, windows-2025, true)
- GitHub Check: precommit (25, ubuntu-24.04-arm)
- GitHub Check: precommit (25, macos-15-intel)
- GitHub Check: precommit (21, macos-15)
- GitHub Check: precommit (25, macos-15)
- GitHub Check: precommit (25, windows-latest)
- GitHub Check: precommit (21, macos-15-intel)
- GitHub Check: precommit (25, ubuntu-latest)
- GitHub Check: precommit (21, windows-latest)
- GitHub Check: precommit (21, ubuntu-24.04-arm)
- GitHub Check: precommit (21, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-24.04-arm)
- GitHub Check: assemble (25, ubuntu-latest)
- GitHub Check: assemble (25, ubuntu-24.04-arm)
- GitHub Check: assemble (25, windows-latest)
- GitHub Check: assemble (21, windows-latest)
- GitHub Check: detect-breaking-change
- GitHub Check: Analyze (java)
9100f2c to
0b686af
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)
285-287: Avoid leaking internalexcludesarray; return a defensive copy insteadReturning the backing
String[]lets callers mutate internal state of aSourceFieldMapper, which can violate immutability assumptions and cause hard‑to‑trace bugs under concurrent access. Consider returning a copy instead.- public String[] getExcludes() { - return excludes; - } + public String[] getExcludes() { + return excludes.clone(); + }CHANGELOG.md (1)
40-40: Changelog entry correctly documents the new public getterThe new bullet accurately reflects the
SourceFieldMapperAPI change; no functional concerns. If you want to polish wording, consider “…for use with k‑NN derived source paths” for slightly smoother phrasing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md(1 hunks)server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: gradle-check
- GitHub Check: Analyze (java)
- GitHub Check: precommit (25, macos-15-intel)
- GitHub Check: assemble (25, ubuntu-24.04-arm)
- GitHub Check: precommit (25, macos-15)
- GitHub Check: precommit (25, ubuntu-24.04-arm)
- GitHub Check: precommit (21, windows-2025, true)
- GitHub Check: assemble (25, windows-latest)
- GitHub Check: precommit (21, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-24.04-arm)
- GitHub Check: precommit (25, ubuntu-latest)
- GitHub Check: precommit (25, windows-latest)
- GitHub Check: precommit (21, macos-15-intel)
- GitHub Check: precommit (21, ubuntu-24.04-arm)
- GitHub Check: assemble (25, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-latest)
- GitHub Check: assemble (21, windows-latest)
- GitHub Check: precommit (21, windows-latest)
- GitHub Check: precommit (21, macos-15)
- GitHub Check: detect-breaking-change
| } | ||
|
|
||
| public String[] getExcludes() { | ||
| return excludes; |
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.
Lets return immutable version of excludes something like
public List<String> getArray() {
return List.of(excludes);
}
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.
Sure, can we do excludes.clone()? To avoid changing the return type.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20205 +/- ##
============================================
- Coverage 73.30% 73.22% -0.09%
+ Complexity 71804 71718 -86
============================================
Files 5793 5793
Lines 328160 328174 +14
Branches 47266 47267 +1
============================================
- Hits 240559 240290 -269
- Misses 68295 68622 +327
+ Partials 19306 19262 -44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sahil Buddharaju <sahilbud@amazon.com>
0b686af to
a4f4556
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)
285-287: Defensive copy viaclone()is correct; consider documenting contractReturning
excludes.clone()cleanly exposes the configuration without leaking internal mutable state, and keeps the existingString[]-based API surface intact. From a correctness and encapsulation standpoint this looks good.As a minor follow‑up, consider adding brief Javadoc on
getExcludes()clarifying that:
- it never returns
null, and- it returns a copy of the excludes array that callers are free to modify.
That will help future users of this public API understand the method’s guarantees.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md(1 hunks)server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: gradle-check
|
❕ Gradle check result for a4f4556: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Description
This change is adding a public getter function for the excludes list in SourceFieldMapper.
Related Issues
Resolves #20201
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.