Skip to content

Make use of Java 17 pattern matching switch statements #17909

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

JaySabva
Copy link

Description

Changed if-else instaceof check to JAVA 17 pattern matching switch

Related Issues

Resolves #17874

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

Copy link
Contributor

❌ Gradle check result for 38eeb9d: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❕ Gradle check result for f3e2454: 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.

Copy link

codecov bot commented Apr 12, 2025

Codecov Report

Attention: Patch coverage is 79.10448% with 14 lines in your changes missing coverage. Please review.

Project coverage is 72.44%. Comparing base (1628152) to head (f3e2454).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
...java/org/opensearch/index/search/NestedHelper.java 76.92% 5 Missing and 7 partials ⚠️
...src/main/java/org/opensearch/ExceptionsHelper.java 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #17909   +/-   ##
=========================================
  Coverage     72.43%   72.44%           
- Complexity    66789    66809   +20     
=========================================
  Files          5449     5452    +3     
  Lines        309085   309181   +96     
  Branches      44979    44963   -16     
=========================================
+ Hits         223899   223998   +99     
+ Misses        66906    66843   -63     
- Partials      18280    18340   +60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

❌ Gradle check result for f2ae0fa: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

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

Thanks for raising a PR @JaySabva! There are other classes as well. For ex:

  1. https://github.com/opensearch-project/OpenSearch/blob/main/plugins/repository-s3/src/internalClusterTest/java/org/opensearch/repositories/s3/S3BlobStoreRepositoryTests.java#L357-L368
  2. https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/util/Util.java#L135-L145
    To name a few.
    Also, DCO check is failing. Can you sign your commit with git commit -s --amend and push again? To sign the commits you need to include -s flag

return true;
}
case OpenSearchToParentBlockJoinQuery ostpbjq -> ostpbjq.getPath() != null;
case null -> true;
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this map to default case?

Copy link
Author

@JaySabva JaySabva Apr 14, 2025

Choose a reason for hiding this comment

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

I think that will raise null pointer exception I tried that in my scratch file.

} else {
return true;
}
case null -> true;
Copy link
Member

Choose a reason for hiding this comment

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

Here too

@JaySabva
Copy link
Author

I thought only instance of if else.

Sure I will make changes.

Copy link
Contributor

❌ Gradle check result for 5f4340f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Make use of Java 17 pattern matching switch statements where possible
2 participants