Skip to content

Skip null map values during expression expansion - #3597

Merged
velo merged 2 commits into
OpenFeign:masterfrom
kdelay:fix/map-null-value-expansion
Oct 5, 2026
Merged

velo merged 2 commits into
OpenFeign:masterfrom
kdelay:fix/map-null-value-expansion

Conversation

@kdelay

@kdelay kdelay commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

SimpleExpression#expandMap calls toString() on each map value, so a @Param map with a null value fails:

@RequestLine("GET /settings{;props}")
void matrixParametersWithMap(@Param("props") Map<String, Object> props);
// props = {account=a, name=null}
// NullPointerException: Cannot invoke "Object.toString()" because "raw" is null

A simple {props} expression fails the same way. expandIterable and the collection branch from #3587 already skip null elements, so this skips a null map value too. The request above now goes to /settings;account=a.

Tests: new cases in UriTemplateTest and FeignTest fail with the NPE on master and pass here. mvn -pl core install -Pdev: 735 tests, 0 failures (OptionsTest excluded, it times out locally on master too).

kdelay and others added 2 commits October 4, 2026 18:57
Expressions.SimpleExpression#expandMap called toString() on every map
value, so a Map parameter with a null value failed with a
NullPointerException when expanded by {;params} or {params}. Skip the
entry instead, matching how expandIterable treats null elements.
Signed-off-by: Marvin Froeder <velo.br@gmail.com>

@velo velo 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.

Thanks! I pushed a follow-up commit: the three null checks in expandMap are now one loop, there's a test for a map whose values are all null, the FeignTest case that repeated UriTemplateTest is gone, and the CHANGELOG wording is simpler.

@velo
velo enabled auto-merge October 5, 2026 11:35
@velo
velo merged commit d0cb674 into OpenFeign:master Oct 5, 2026
3 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