Skip to content

Commit b0f233d

Browse files
Evaluate kind only if property is known
1 parent b8dfd19 commit b0f233d

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/JacksonErrorHelper.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ final class JacksonErrorHelper {
3939

4040
static ProblemBuilder resolveMismatchedInput(
4141
MismatchedInputException e, TypeNameMapper typeNameMapper) {
42-
Optional<String> property = resolvePropertyPath(e);
43-
Optional<String> kind = typeNameMapper.map(e.getTargetType());
42+
Optional<String> optionalProperty = resolvePropertyPath(e);
4443

4544
ProblemBuilder builder = Problem.builder().status(HttpStatus.BAD_REQUEST.value());
4645

47-
property.ifPresent(
48-
it -> {
46+
optionalProperty.ifPresent(
47+
property -> {
48+
String kind = typeNameMapper.map(e.getTargetType()).orElse(null);
49+
4950
builder.detail(TYPE_MISMATCH_DETAIL);
50-
builder.extension(PROPERTY_EXTENSION, it);
51-
builder.extension(KIND_EXTENSION, kind.orElse(null));
51+
builder.extension(PROPERTY_EXTENSION, property);
52+
builder.extension(KIND_EXTENSION, kind);
5253
});
5354

5455
return builder;

0 commit comments

Comments
 (0)