Skip to content

Avoid going through Optional - #26138

Merged
pzygielo merged 1 commit into
eclipse-ee4j:mainfrom
pzygielo:reduce
Jul 9, 2026
Merged

Avoid going through Optional#26138
pzygielo merged 1 commit into
eclipse-ee4j:mainfrom
pzygielo:reduce

Conversation

@pzygielo

@pzygielo pzygielo commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@pzygielo
pzygielo marked this pull request as ready for review July 8, 2026 13:44
Stream<File> libs = findFiles(appInstall, libFilter);
Stream<File> derbyLibs = findFiles(derbyLibDir, derbyFilter);
return Stream.of(modules, libs, derbyLibs).reduce(Stream::concat).orElseGet(Stream::empty).map(TO_URL)
return Stream.of(modules, libs, derbyLibs).flatMap(s -> s).map(TO_URL)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s -> s is the same as Function.identity(), am I right?
But ... where is the Optional? Aha, I see, the original code's Stream.reduce method returns Optional<Stream<File>>, while Stream.empty returns Stream<File>.

And you are right:

"Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)"

@dmatej dmatej added this to the 8.0.4 milestone Jul 9, 2026
@dmatej dmatej added the bug Something isn't working label Jul 9, 2026
@pzygielo
pzygielo merged commit a51f9c4 into eclipse-ee4j:main Jul 9, 2026
5 checks passed
@pzygielo
pzygielo deleted the reduce branch July 9, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants