Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private TargetBundle[] getBundles(boolean allBundles) {
}
}

TargetBundle[] allResolvedBundles = all.toArray(new TargetBundle[all.size()]);
TargetBundle[] allResolvedBundles = all.toArray(TargetBundle[]::new);
if (allBundles) {
return allResolvedBundles;
}
Expand Down Expand Up @@ -595,7 +595,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript
}

// Return matching bundles, if we are organizing by feature, do not create invalid target bundles for missing bundle includes
List<TargetBundle> result = getMatchingBundles(bundles, included.toArray(new NameVersionDescriptor[included.size()]), !containsFeatures);
List<TargetBundle> result = getMatchingBundles(bundles, included.toArray(NameVersionDescriptor[]::new), !containsFeatures);

// Add in missing features as resolved bundles with error statuses
if (containsFeatures && !missingFeatures.isEmpty()) {
Expand All @@ -607,7 +607,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript
}
}

return result.toArray(new TargetBundle[result.size()]);
return result.toArray(TargetBundle[]::new);
}

/**
Expand All @@ -627,9 +627,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript
*/
static List<TargetBundle> getMatchingBundles(TargetBundle[] collection, NameVersionDescriptor[] included, boolean handleMissingBundles) {
if (included == null) {
ArrayList<TargetBundle> result = new ArrayList<>();
result.addAll(Arrays.asList(collection));
return result;
return new ArrayList<>(Arrays.asList(collection));
Copy link
Member

Choose a reason for hiding this comment

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

If the list should not be modified and you are sure the array doesn't contain null elements, you could also use List.of().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if null can happen or not, so my proposal would be to leave it as it.

}
// map bundles names to available versions
Map<String, List<TargetBundle>> bundleMap = new HashMap<>(collection.length);
Expand Down Expand Up @@ -995,7 +993,7 @@ public TargetFeature[] getAllFeatures() {
}
}

fFeatures = result.values().toArray(new TargetFeature[result.size()]);
fFeatures = result.values().toArray(TargetFeature[]::new);
return fFeatures;
}

Expand Down
Loading