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

Use collections conveniences in static initializers #41374

Merged
merged 4 commits into from
Apr 19, 2019
Merged

Conversation

jasontedor
Copy link
Member

This commit replaces the construction of some collections in static initializers with new collection convenience methods that are available now that we have bumped the minimum Java language level to be higher than Java 8.

This commit replaces the construction of some collections in static
initializers with new collection convenience methods that are available
now that we have bumped the minimum Java language level to be higher
than Java 8.
@jasontedor jasontedor added >non-issue :Core/Infra/Core Core issues without another label v8.0.0 labels Apr 19, 2019
@jasontedor jasontedor requested a review from jpountz April 19, 2019 13:55
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Nice, it makes things easier to read.

@@ -128,13 +123,13 @@ private QueryAnalyzer() {
* @param indexVersion The create version of the index containing the percolator queries.
*/
static Result analyze(Query query, Version indexVersion) {
Class<?> queryClass = query.getClass();
Class<? extends Query> queryClass = query.getClass();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is creating more problems than it helps?

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed 3cad419. My IDE was throwing a warning at me that the map lookup was suspicious because queryClass might not be Class<? extends Query> but I think that 3cad419 is a better way to ensure this and remove the IDE warning.

@@ -99,7 +99,11 @@ private Sets() {
public static <T> SortedSet<T> sortedDifference(Set<T> left, Set<T> right) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related to you change, but I'm seeing some inconsistencies wrt whether the return value of this method is assumed mutable. Reconfigurator seems to assume it is immutable and creates a TreeSet out of it while RestGetMappingAction modidies the result of this method. The reason why I was looking at this was to figure out whether we should actually have a toSortedSet method in this class, or whether what we actually needed was a toUnmodifiableSortedSet.

Copy link
Member Author

@jasontedor jasontedor Apr 19, 2019

Choose a reason for hiding this comment

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

I pushed e9dd166.

Copy link
Contributor

@jpountz jpountz 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 aligning the API with how it's used.

@jasontedor jasontedor merged commit a5ad5f7 into master Apr 19, 2019
@jasontedor jasontedor deleted the java-collections branch April 19, 2019 19:27
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
This commit replaces the construction of some collections in static
initializers with new collection convenience methods that are available
now that we have bumped the minimum Java language level to be higher
than Java 8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants