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

filter out empty or null string while parsing urls #741

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

tulikabhatt
Copy link
Contributor

@tulikabhatt tulikabhatt commented Jan 17, 2025

Issue 664: Filtering out empty or null string before creating the URLs array

URL[] urls = new URL[urlStrings.length];
final String[] validUrlStrings = Arrays.stream(urlStrings)
.filter(s -> s != null && !s.isEmpty())
.toArray(String[]::new);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're already using a Stream, you might as well bring the new Url(s) to it. Arrays.stream().filter().map().toArray(Url[]). Avoid allocating an intermediate String[].

@rgallardo-netflix rgallardo-netflix merged commit 56adbe4 into Netflix:2.x Jan 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants