Skip to content

fix: NPE risk in ExamplesExporter.exportHeaders() when header values are empty - #2070

Merged
lbroudoux merged 2 commits into
microcks:masterfrom
ashnaaseth2325-oss:fix/examples-exporter-empty-header-values
May 6, 2026
Merged

lbroudoux merged 2 commits into
microcks:masterfrom
ashnaaseth2325-oss:fix/examples-exporter-empty-header-values

Conversation

@ashnaaseth2325-oss

@ashnaaseth2325-oss ashnaaseth2325-oss commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Prevent a runtime exception when exporting headers by safely handling empty header value sets in ExamplesExporter. This updates exportHeaders() to avoid unsafe Optional#get() usage.


Sites changed

ExamplesExporter#exportHeaders


Notes

Replaces unsafe findFirst().get() with ifPresent(...) to avoid NoSuchElementException when a header has no values. Behavior remains unchanged for valid inputs; empty headers are now safely skipped instead of causing a crash.

See #2058

@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown

👋 @ashnaaseth2325-oss

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@ashnaaseth2325-oss

Copy link
Copy Markdown
Contributor Author

Hello @yada @lbroudoux,
This PR fixes empty header values crash in exportHeaders() by replacing unsafe Optional#get() with ifPresent()

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@lbroudoux lbroudoux added java Pull requests that update Java code kind/task labels May 6, 2026
@lbroudoux lbroudoux added this to the 1.15.0 milestone May 6, 2026
@lbroudoux
lbroudoux merged commit ef5891c into microcks:master May 6, 2026
2 of 6 checks passed
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

🎉 @ashnaaseth2325-oss

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code kind/task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants